This class of queries can be used to combine one or more queries to come up with a more complex query. Some compound queries convert scoring queries into non-scoring queries, and combine multiple scoring and non-scoring queries. We will look at the following compound queries:
- Constant score query
- Bool query
Elasticsearch supports querying both structured data and full text. While full-text queries need scoring mechanisms to find the best matching documents, structured searches don't need scoring. The constant score query allows us to convert a scoring query which normally runs in query context to a non-scoring filter context. The constant score query is a very important tool in your toolbox.
For example, the term query is normally run in a query context. That means when Elasticsearch executes a term query, it not only filters the documents but also scores all of them:
GET /amazon_products/products/_search { "query": { "term": { "manufacturer...