liveBook · Manning

Boosting query

As explained in Elasticsearch in Action, Second Edition

A boosting query is an Elasticsearch compound query that promotes documents matching a positive query and optionally demotes documents matching a negative query by adjusting their relevance scores.

A boosting query promotes documents matching a positive query while demoting, rather than removing, documents matching a negative query. It is useful when relevance should favor one group but still retain less-preferred matches. section 11.5 section 11.8

Prefer affordable LG televisions

Search for televisions with a positive term query, then place televisions priced at $2,500 or more lower in the results by setting negative_boost to 0.5. The expensive televisions remain searchable; their relevance scores are recalculated downward. section 11.5

The positive and negative parts can contain leaf queries or compound queries. For example, a bool query can match televisions positively and Sony products negatively, then apply the same negative_boost mechanism. section 11.5

Use the query when:

  • A preferred category should rank first without excluding other matching documents. section 11.5
  • A measurable condition, such as high price or a brand, should lower relevance rather than act as a hard filter. section 11.5
  • Several matching conditions must be combined inside positive or negative clauses. section 11.5 section 11.2

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Defines positive, negative, and negative_boost parts with REST examples and nested bool queries, without detailing scoring internals.
Examples
Demonstrates LG televisions, expensive products, Sony brands, term queries, range queries, and nested bool queries.
What it assumes
Assumes familiarity with leaf queries and relevance scores while establishing compound-query composition through concrete examples.
What you can do after
Apply it via Elasticsearch Query DSL to promote preferred documents and demote matches to a negative query.
How it connects
Connects leaf queries, bool queries, compound queries, relevance scoring, filters, constant_score, and function_score.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.