liveBook · Manning

Boost

As explained in Elasticsearch in Action, Second Edition

Boosting is the technique of increasing the importance of selected query fields so matching documents receive higher relevance scores.

Boosting increases the importance of selected matches so they receive higher relevance scores and tend to appear earlier in Elasticsearch results. It is useful when a search spans several fields but a match in one field matters more to users—for example, a book title should usually outweigh the same words appearing only in a synopsis or tags. Full-text hits carry a positive floating-point `_score`; higher scores rank first. Elasticsearch calculates these relevance scores with BM25, then a boost adjusts the weight given to chosen criteria. section 2.3.4

For a `multi_match` query, append `^` and a numeric factor to a field name. `title^3` means that a title match is weighted three times as strongly as a synopsis match. This does not restrict the search to titles: both fields remain searchable. It changes the ordering when otherwise relevant documents compete. section 2.3.5 section 10.8.4

Listing 2.11 A multi_match query that boosts a field’s importance
GET books/_search
{
  "query": {
    "multi_match": {                      #1
      "query": "Java",
      "fields": ["title^3","synopsis"]    #2
    }
  }
}
#1 Searches through multiple fields
#2 A caret followed by the boost number indicates the field being boosted.

Use this request as the basic pattern: search `title` and `synopsis`, but favor documents whose title matches `Java`. The caret and number belong in the field entry, not beside the query text. section 2.3.5

Favor a book title over tags

A general search bar can accept `C# Guide` without asking the user which field to search. Configure the query to search both `title` and `tags`, using `title^2`. A document containing the words in its title receives a higher score than one containing them only in tags. ```json GET books/_search { "query": { "multi_match": { "query": "C# Guide", "fields": ["title^2", "tags"] } } } ``` section 10.8.4

Boosting can also assign a score at the query level. A plain `match_all` query gives every returned document a default score of `1.0`; adding `"boost": 2` raises that score. This is appropriate when all documents matched by a query need the same predefined score, rather than when one text field should outweigh another. section 10.3.1

Filters normally run without a relevance score. Wrap a filter in `constant_score` and supply `boost` to give every filtered result the same nonzero score. For example, a rating-range filter can receive score `5.0`. Combined with a `match` query in a `bool` query, a `constant_score` clause can promote all black TVs by `3.5` while still requiring a product match. section 11.4

A `bool` query can boost results through its `should` clauses as well. Documents must satisfy the `must` criteria, while matching optional `should` criteria adds weight to their relevance score. In the TV example, an LG TV matching price or “4K Ultra HD” preferences rises from a score of `4.4325914` to `14.9038105`. Use `minimum_should_match` when optional criteria must meet a minimum count. section 11.3.6

Choose the boosting form that matches the ranking decision:

  • Use `field^factor` in `multi_match` when one searched field, such as `title`, is more meaningful than another. section 2.3.5
  • Use a query-level `boost` when the entire query needs a predefined score, including `match_all`. section 10.3.1
  • Use `constant_score` when a filter needs a fixed score, or `should` clauses when optional matches should add relevance. section 11.4 section 11.3.6

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains caret field factors, query boosts, constant scores, and should-clause score increases through JSON requests and returned scores.
Examples
Uses Java and C# book searches, rating-filtered products, and LG TVs with price, color, and 4K preferences.
What it assumes
Introduces boosting from multi-field search and basic relevance scores without requiring prior field-selection knowledge.
What you can do after
Apply it via Elasticsearch Query DSL to raise field, query, filtered-result, or optional-match relevance.
How it connects
Connects relevance scoring with multi_match, match_all, constant_score, bool queries, should clauses, and minimum_should_match.

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.