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 |
|
|
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. |