An inverted index records which documents contain a term. The posting for a rare product code may be tiny, while a word like “service” appears almost everywhere. Analysis choices such as case folding and tokenization decide whether a query and a document even share a term. Rankings only operate on the resulting candidates.
Repeated words have diminishing returns
With document length and IDF fixed, the first matching term makes a large contribution. The curve shows the BM25 frequency factor with k₁ = 1.2 at average document length.
Why it exists
Term frequency rewards a document for using a matching word. Inverse document frequency gives a rare word more weight. BM25 also limits the benefit of repetition and takes field length into account. A short runbook mentioning a precise failure code might therefore outrank a long incident archive.
View diagram · Query executionTF, IDF and field length affect the order of eligible matches. Full size
Words to know
Posting
An index entry that identifies a matching document and may carry term frequency and positions.
Refresh
The operation that makes newly indexed data visible to searches in Elasticsearch.
How it works
Step through the idea, or press Play.
Step 1 of 3
Trace retrieval. An inverted index maps analyzed terms to postings. Intersect required terms and apply permission filters before returning a result. Phrase queries need position information or a verification step.
Explain the score. TF-IDF weighs term frequency by rarity. BM25 saturates the benefit of repeating a term and adjusts for field length. Compare judgments on representative queries before changing k1 or b.
Separate freshness. Elasticsearch refresh exposes new segments to searches. A successful write and a searchable document are distinct milestones. Across shards, merge candidate hits, then fetch the selected documents.
Understand it
Start here
The missing reset guide
An engineer publishes a reset guide and immediately searches for it. Follow the guide from the writer’s view to the results page to see where a missing document and a low-ranked one diverge.
The missing reset guide
Check refresh, terms and access filters.
Structure
Query execution
Query execution
TF, IDF and field length affect the order of eligible matches.
A relevance experiment
Compare a two-sentence reset guide containing “reset token” once with a long troubleshooting catalog that repeats it eight times. Record their ranks for five judged queries before tuning length normalization. Test visibility separately by indexing a new guide and searching before and after refresh.
An error identifier and a body paragraph often need separate fields. Users searching an exact identifier expect a precise match; people describing symptoms need tokenized text. Store and query each field according to its use. Phrase search also needs information about term positions so a phrase match can distinguish the same words scattered across a long article.
Evaluate a change against people’s queries
Build a small set containing a rare code, a frequent symptom, a paraphrase and a recent document. Record which results engineers consider useful. Compare their positions before and after tuning, with access rules kept fixed. Track publication-to-search delay separately so a slow refresh cannot masquerade as a relevance regression.
Inspect candidates first
Check refresh, terms and access filters.
Tune scoring for a missing candidate
A ranker can only score documents it receives.
Summary
The whole topic in one minute.
Trace analysis, visibility, candidate retrieval and scoring in order. Change a scoring parameter only after the desired item is visible and eligible.