Difference Between Inverted Index and Forward Index



Inverted Index and Forward Index are data structures used to search text in a document or set of documents.

Inverted Index

Inverted Index stores the words as index and document name(s) as mapped reference(s).

Forward Index

Forward Index stores the document name as index and word(s) as mapped reference(s).

The following are some of the important differences between the Inverted Index and Forward Index.

Sr. No. Key Inverted Index Forward Index
1 Mapping Pattern Inverted Index stores the words as index and document name(s) as mapped reference(s). Forward Index stores the document name as index and word(s) as mapped reference(s).
2 Index Building Process
  • Scan the document, prepare a list of unique words.

  • Prepare a list of indexes of all unique words and map them to document search.

  • Repeat the above steps for all the documents.

  • Scan the document, prepare list of unique words.

  • Map all the words to document as an index.

  • Repeat the above steps for all the documents.

3 Indexing In the Inverted index, indexing is slow as each word has to be checked before preparing the index. In the forward index, indexing is fast as keywords are appended when found.
4 Searching In the Inverted index, the search is quite fast. In the forward index, the search is slow.
5 Example
Word Documents
-------------------------
Welcome doc1
Hello doc1, doc3
Hi doc2
-------------------------
Word Documents
-------------------------
doc1 Welcome, Hello
doc2 Hi
doc3 Hello
-------------------------
6 Duplicity In the Inverted index, no duplicate keyword is stored in an index. In the forward index, duplicate keywords can be present in an index like 'Hello'.
7 Real-Life Examples A glossary at end of the index, Reverse Lookup. Table of Content at the start of the book, DNS lookup.
Updated on: 2020-04-15T08:22:52+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements