IR Indexing
IR Indexing
IR Indexing
(1998,www.cnn.com)
(1998,news.google.com)
(1998,www.cnn.com) (1998,news.google.com)
(Her,news.bbc.co.uk)
(Every,www.cnn.com) (Every,www.cnn.com)
(I,www.cnn.com)
(Her,news.google.com) (Her,news.bbc.co.uk)
(Jensen's,www.cnn.com)
(I'm,news.bbc.co.uk) (Her,news.google.com)
(I,www.cnn.com)
(I'm,news.bbc.co.uk)
(Jensen's,www.cnn.com)
Disk
BSBI - Block sort-based indexing
BlockSortBasedIndexConstruction
BlockSortBasedIndexConstruction()
1 n←0
2 while (all documents not processed)
3 do block ← ParseNextBlock()
4 BSBI-Invert(block)
5 WriteBlockToDisk(block, fn )
6 MergeBlocks(f1 , f2 ..., fn , fmerged )
BSBI - Block sort-based indexing
Analysis of BSBI
• The dominant term is O(TlogT)
• T is the number of TermID,DocID pairs
• But in practice ParseNextBlock takes the most time
• Then MergingBlocks
• Again, disk seeks times versus memory access times
BSBI - Block sort-based indexing
Analysis of BSBI
• 12-byte records (term, doc, meta-data)
• Need to sort T= 100,000,000 such 12-byte records by term
• Define a block to have 1,600,000 such records
• can easily fit a couple blocks in memory
• we will be working with 64 such blocks
• 64 blocks * 1,600,000 records * 12 bytes = 1,228,800,000 bytes
• Nlog2N comparisons is 5,584,577,250.93
• 2 touches per comparison at memory speeds (10e-6 sec) =
• 55,845.77 seconds = 930.76 min = 15.5 hours
Index Construction
Overview
• Introduction
• Hardware
• BSBI - Block sort-based indexing
• SPIMI - Single Pass in-memory indexing
• Distributed indexing
• Dynamic indexing
• Miscellaneous topics
Single-Pass In-Memory Indexing
SPIMI
• BSBI is good but,
• it needs a data structure for mapping terms to termIDs
• this won’t fit in memory for big corpora
• Straightforward solution
• dynamically create dictionaries
• store the dictionaries with the blocks
Single-Pass In-Memory Indexing
SPIMI
• BSBI is good but,
• it needs a data structure for mapping terms to termIDs
• this won’t fit in memory for big corpora
• Straightforward solution
• dynamically create dictionaries
• store the dictionaries with the blocks
Single-Pass In-Memory Indexing
SPIMI-Invert(tokenStream)
1 outputF ile ← NewFile()
2 dictionary ← NewHash()
3 while (f ree memory available)
4 do token ← next(tokenStream)
5 if term(token) ∈ / dictionary
6 then postingsList ← AddToDictionary(dictionary, term(token))
7 else postingsList ← GetPostingsList(dictionary, term(token))
8 if f ull(postingsList)
9 then postingsList ← DoublePostingsList(dictionary, term(token))
10 AddToPostingsList(postingsList, docID(token))
11 sortedT erms ← SortTerms(dictionary)
12 WriteBlockToDisk(sortedT erms, dictionary, outputF ile)
13 return outputF ile
Single-Pass In-Memory Indexing