Reference · Cheat sheet
The inverted index
The compressed essence. Print it, pin it.
From lesson 0004See also glossary
Structure
- Term dictionary — sorted list of every unique term in a field.
- Postings list — per term, the sorted list of doc IDs containing it (may also carry frequency, positions, offsets).
- One inverted index per field —
title and body are separate.
| Term (sorted) | Postings | doc freq (n) |
| brown | [1, 2] | 2 |
| fox | [1] | 1 |
| the | [1, 2] | 2 |
Why it's fast
- Term lookup = binary search on the sorted dictionary (sub-linear), then read postings. No document scan.
- AND of terms = merge-walk two sorted doc-ID lists in one pass (merge join).
- Prefix / range (
quic*) = one contiguous slice of the dictionary → cheap.
- Leading wildcard (
*ick) = matches scattered → must scan whole dictionary → slow.
Feeds BM25 (lesson 0002)
| BM25 input | Comes from |
n (for IDF) | length of the term's postings list = document frequency |
f(t,D) (TF) | term frequency stored in the postings, at index time |
| field-length norm | field length computed & stored at index time |
The whole path
text → analyse → terms → seek term dictionary → merge postings → candidate docs → BM25 → ranked hits
Inspect it
GET /index/_termvectors/<id> // term_freq + doc_freq per term
{ "fields": ["title"], "term_statistics": true, "field_statistics": true }
← lesson 0004 · Source: Definitive Guide — Inverted index