Inverted Index

Core data structure mapping terms to document lists 

An Inverted Index is a core data structure used by search engines to efficiently find documents that contain a given word or term. It is essentially a mapping from terms (words) to the list of documents (or document IDs) in which those terms appear.


🔁 Inverted Index Explained in Layman's Terms:

Imagine you're in a library with 1000 books, and you want to find all the books that mention the word "cat".

  • Instead of checking each book one by one (which is slow),

  • You keep a "reverse dictionary":
    For each word, it tells you which books contain it.


📚 Example:

Let’s say you have 3 documents:

Doc1: "cat eats fish"

Doc2: "dog eats bone"

Doc3: "cat and dog"


The inverted index would look like:

Term

Document List

and

[Doc3]

bone

[Doc2]

cat

[Doc1, Doc3]

dog

[Doc2, Doc3]

eats

[Doc1, Doc2]

fish

[Doc1]

So, if someone searches for “cat”, the engine instantly returns [Doc1, Doc3].


🧠 Key Idea:

  • A normal index maps from document → words.

  • An inverted index maps from word → documents.


🛠 Use Case:

  • Web Search Engines (Google, Bing)

  • Enterprise Search (e.g., Elasticsearch, Solr, Vespa)

  • Local Document Search (e.g., PDF or code search)



Distributed by Gooyaabi Templates | Designed by OddThemes