An inverted index maps terms to documents containing them.
Document : "red apple" Document : "green apple"
Inverted index:
- "red" → []
- "green" → []
- "apple" → [, ]
Searching "apple" returns documents [, ] in time using space for the index. No scanning. This is how Google searches billions of pages instantly.