One of the main characteristics of ElasticSearch is schemaless storage. So due to its schemaless nature two kinds of filters are required to check if a field exists in a document (the exists
filter) or if it is missing (the missing
filter).
You need a working ElasticSearch cluster and the data populated with the populate script.
For executing existing and missing filters, we need to perform the following steps:
To search all the
test-type
documents that have a field calledparsedtext
the query will be as follows:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "filtered": { "filter": { "exists": { "field":"parsedtext" } }, "query": { "match_all": {} } } } }'
To search all the
test-type
documents that do not have a field calledparsedtext
, the query will be as follows...