Compound queries
As we have already discussed, in addition to simple queries, ElasticSearch exposes a few compound queries that can be used to connect multiple queries together or are used to control the behavior of another query. You may wonder whether you need such functionality. In fact, if you are interested in making your search better, you'll use the following queries somewhere in your journey with ElasticSearch. A simple example is combining a simple term query with a phrase query in order to get better search results. But for now, let's stick to the query description.
The bool query
A bool query allows us to wrap a virtually unbounded number of queries and connect them with a logical value by using one of the following sections:
should
: The query wrapped into this section may or may not have a match (the number of the queries in theshould
section that need to match is controlled by theminimum_should_match
parameter).must
: The query wrapped into this section must match in order...