Inverted Index
Like the index pages at the back of a book, this is a way of searching by building a per-word list in advance.
Problem: reading 100,000 commits one by one every time someone asks "find the commits that contain login" is slow (O(n)).
Solution: build per-word lists in advance when commits are created.
keyword_index:
"login" → [d4e5f6, ...]
"payment" → [g7h8i9, ...]
author_index:
"Alice" → [a1b2c3, d4e5f6, g7h8i9]When searching, you just pull out the list for that word → effectively an O(1) lookup + output proportional only to the number of results.
- Keyword normalization rule: split the message on spaces → lowercase everything (lower)
- The key point is to update both indexes on every
COMMIT
Summary
| Concept | Plain-language summary |
|---|---|
| Inverted index | Build a per-word list book in advance so searches are answered instantly |
Source: Codyssey-B1/B5-2
