However how can I write a query that represents the expression: A and ((C or
D) and (X or Y))? I plan to use a Python dictionary and convert it into a
JSON object.
the example that you have in your email does not in fact corresponds to A
and (C or D). Both C and D are optional in this case and only A is
mandatory. It translates to +A C D, where + denotes terms that must be found
in the document, and C and D are only optional. It seems that documentation
for boolean filter ( Elasticsearch Platform — Find real-time answers at scale | Elastic) has
similar example and can be little confusing. I think in your particular
example the optional (should) clauses have no effect on the result data set
since it will filter all documents having A clause present. If it were a
boolean query and not filter then the effect of optional (should) clauses
would be reflected in document relevancy. Check boolean query doc Elasticsearch Platform — Find real-time answers at scale | Elastic for
further info.
Note that both boolean queries and boolean filters can contain nested
queries (or filters) thus creating more complex queries is possible (think
of using bool query instead of term queries in your particular example).
However how can I write a query that represents the expression: A and ((C
or D) and (X or Y))? I plan to use a Python dictionary and convert it into a
JSON object.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.