Using the exists query
One of the main characteristics of Elasticsearch is schema-less indexing capability. Records in Elasticsearch can have missing values. Due to its schema-less nature, two kinds of queries are required:
Exists field: This is used to check if a field exists in a document
Missing field: This is used to check if a field is missing
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via the command line, you need to install curl
for your operative system.
To correctly execute the following commands, you need an index populated with the chapter_05/populate_query.sh
script available in the online code.
How to do it...
For executing existing and missing filters, we will perform the following steps:
To search all the test-type documents that have a field called
parsedtext
, the query will be:curl -XPOST 'http://127.0.0.1:9200/test-index/test...