Skip to main content
InterviewHubPRO
Section Overview
Q12

Question 12 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

24%
Elasticsearch & Lucene (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

How does the BM25 relevance ranking algorithm calculate scores?

senior LevelSystem Design

In Simple Words: Okapi BM25 is the default scoring algorithm in Lucene / Elasticsearch, improving upon classical TF-IDF:

  1. Term Frequency (TF): How often the term appears in the document. BM25 uses asymptotic saturation, preventing a document with 100 mentions of a word from dominating one with 5 mentions.
  2. Inverse Document Frequency (IDF): Rare terms across the index get much higher weight than common terms like "the" or "is".
  3. Field Length Normalization: Shorter fields containing the term score higher than massive documents where the term is just an incidental mention.