liveBook · Manning

Relevance

As explained in Elasticsearch in Action, Second Edition

Relevance is the degree to which a search result matches a query's intent or information need.

Relevance is how closely a search result matches a user’s query or information need. In full-text search, matching is not simply yes or no: documents receive positive scores and are ordered so stronger matches appear first. section 1.2.1 section 3.4

This matters when people search text with ambiguous terms. A bookstore search for “Java” should favor books about the programming language rather than documents about the Indonesian island or coffee. Relevant, fast results also help preserve the user’s search experience. section 10.0 section 10.1

Elasticsearch treats relevance differently across query types:

  • Structured-data searches seek exact matches and ordinarily do not attach a relevance score. section 1.2.1
  • Full-text queries search unstructured text and return scored documents for relevance-based ranking. section 10.0 section 10.13
  • The common match query searches text fields and scores matching documents with a relevance algorithm. section 10.13

By default, Elasticsearch uses the BM25 similarity algorithm. Scores depend on factors including term frequency, inverse document frequency, and field length; Elasticsearch also offers other similarity algorithms for ranking matching documents. section 3.4.1 section 3.7

Why a shorter title can rank higher

For a title search for “Java,” “Effective Java” receives a higher score than longer matching titles such as “Head First Java.” All contain the term, but field-length normalization makes the term in the shorter title more relevant in this example. The highest returned score is max_score. section 3.4.1

Figure 3.19 Relevant results for Java in a title search

Compare the returned Java-title documents and their scores to see relevance expressed as ranked search results. section 3.4.1

Relevance is commonly considered alongside precision and recall. These measures help frame whether results are appropriate and closely related to what a user searched for. section 10.1

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Defines scored ranking, explains BM25 factors and field-length normalization, and defers detailed alternatives to similarity algorithms.
Examples
Uses Java book-title searches, Stack Overflow results, retail searches, and a Java-score result figure.
What it assumes
Introduces relevance from search-result examples, then relates it to full-text queries and similarity algorithms.
What you can do after
Apply it via Elasticsearch full-text queries to retrieve and rank documents for text searches.
How it connects
Connects relevance to full-text queries, structured-data exact matching, BM25, similarity algorithms, precision, and recall.

Also explained in

Compare how 11 books explain relevance →

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.