Course contents

How relevance is calculated

Explain BM25 and field evidence without treating score as universal quality.

5 sectionsElasticsearch 9.4.3Not read yet

What you will learn

  • BM25 intuition
  • Fields and alternatives
  • Explaining and comparing scores

Explain BM25 and field evidence without treating score as universal quality.

course-products examples use the teaching mapping and product from chapter 5, “Mapping and field types”. Exercise walkthroughs below use the trainer’s separate public dataset.

Chapter map
  • BM25 intuition
  • Fields and alternatives
  • Explaining and comparing scores

Explain BM25 and field evidence without treating score as universal quality.

The course targets Elasticsearch 9.4.3. Exercise examples use the public products dataset; other requests illustrate separate teaching indices and may require setup or privileges unavailable in the trainer. Responses are shortened fragments; scores may vary. Check deployment and license requirements for advanced features.

01 / 05

BM25 intuition

Rare terms generally distinguish documents better than common ones. Repetition helps with saturation, and field length affects normalization. A short title containing the query can therefore beat a long description. BM25 does not know margin, stock or user intent unless those signals are modeled separately.

Check your understanding
02 / 05

Fields and alternatives

Boost changes a matching clause’s relative contribution; it cannot create a missing match. dis_max emphasizes the strongest branch, while tie_breaker adds a portion of others. A phrase boost in should can prefer close matches without making the phrase mandatory. Evaluate weights over a query set, not a single successful example.

Check your understanding
03 / 05

Explaining and comparing scores

_explain breaks down one document’s score for a query. Scores depend on the query, index statistics, fields and shard distribution. A threshold such as _score>10 does not mean the same quality for all queries. dfs_query_then_fetch can refine distributed term statistics with an extra round trip; it does not replace relevance evaluation.

Explain diagnoses a particular document rather than producing a result page.

POST /course-products/_explain/sku-1
{
  "query": {
    "match": {
      "name": "wireless"
    }
  }
}

How to read this result

Explain diagnoses a particular document rather than producing a result page.

Check your understanding
04 / 05

Catalog reasoning example

Suppose the correct headphones have a short matching name while a popular accessory repeats headphones in a long description. Raw frequency is insufficient. Separate fields, inspect analysis and add a justified name or phrase contribution. Explain both scores. If the desired product is absent from candidates, weight tuning cannot fix it: retrieval precedes ranking.

Check your understanding
05 / 05

Prioritize title matches

In multi_match, the caret notation name^3 gives the name field extra weight relative to an unboosted description. The example searches travel in both fields. Boost changes the contribution of a field; it does not guarantee that every title match universally outranks every description match regardless of content and corpus statistics.

Do not multiply a displayed _score yourself or compare it to a hardcoded target. The engine computes the score from the query and index. In the trainer, a relevance exercise compares document-order relationships and the requested construction. Its task may require a particular boost value even when another value looks plausible.

Try a different scenario

POST /products/_search
{
  "query": {
    "multi_match": {
      "query": "travel",
      "fields": [
        "name^3",
        "description"
      ]
    }
  },
  "size": 2,
  "_source": [
    "name",
    "description"
  ]
}
Elasticsearch response
Shortened response · JSON
{
  "hits": {
    "total": {
      "value": 178,
      "relation": "eq"
    },
    "hits": [
      {
        "_id": "3",
        "_score": 4.8997154,
        "_source": {
          "name": "Sony Travel Speaker 3",
          "description": "Precision equipment for professionals"
        }
      },
      {
        "_id": "13",
        "_score": 4.8997154,
        "_source": {
          "name": "Apple Travel Speaker 13",
          "description": "Premium wireless sound for travel"
        }
      }
    ]
  }
}

How to read this result

The numeric scores show one execution, not permanent expected values. Inspect which field contains travel, then compare the result with an unboosted query to observe the ranking effect.

Apply this in exercise 19

Check your understanding

Answer before expanding each explanation.

1. Why do rare words matter?

They distinguish suitable documents more strongly.

2. Does frequency increase BM25 linearly?

No, term-frequency contribution saturates.

3. Can boosting fix a missing term?

No, it changes contributions from matching clauses.

4. Can scores from different queries be compared?

Not as a universal quality measure.

5. How do you explain one product score?

Use _explain with the same query and index.

Key takeaways

  • They distinguish suitable documents more strongly.
  • No, term-frequency contribution saturates.
  • No, it changes contributions from matching clauses.
  • Not as a universal quality measure.
  • Use _explain with the same query and index.

Official reference

Ready to put this into practice?

Confirm reading to save your place. Reading and exercise progress are tracked separately in this browser using your guest cookie.