11 Compound queries
This chapter covers
- Introduction to compound queries
- Boolean search queries
- Constant score queries
- Boosting queries
- Disjunction maximum queries
- Function score queries
In the last two chapters, we looked at the term-level and full-text queries. We learned about searching structured and unstructured data using a multitude of queries, some producing relevance scores and others working in a filter context where scores were irrelevant. Most of those queries allowed setting a simple search criteria, working on a limited set of fields, such as finding books written by an author or searching for best selling books and so on.
In addition to providing queries for complex criteria, we may sometimes need to boost the scores based on a certain criteria, while at the same time negating the score for negative matches (for example, searching through all books that were launched during a training program may get a positive boost while simultaneously suppressing (negating) books that were pricey). Or maybe we want to set the scores based on custom requirements rather than using Elasticsearch’s inbuilt relevance algorithms.