Using and/or/not filters
When building complex queries, some typical Boolean operation filters are required, as they allow you to construct complex filter relations as in the traditional relational database world.
Any query DSL cannot be completed if there is no and
, or
, or not
filter.
Getting ready
You need a working ElasticSearch cluster and an index populated with the script chapter_05/populate_query.sh
, available in the code bundle for this book.
How to do it...
In order to execute and/or/not filters, perform the following steps:
Search for documents with
parsedtext
equal tojoe
anduuid
equal to11111
in this way:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search?pretty=true' -d '{ "query": { "filtered": { "filter": { "and": [ { "term": { "parsedtext":"joe" } }, { "term": { "uuid":"11111" } } ] }, "query": { "match_all...