Introduction To: Information Retrieval
Introduction To: Information Retrieval
Introduction to
Information Retrieval
Information Retrieval and Web Search
Index construction
How do we construct an index?
What strategies can we use with limited main
memory?
Introduction to Information Retrieval Sec. 4.2
Doc 1 Doc 2
Key step
After all documents have been
parsed, the inverted file is
sorted by terms.
Hardware basics
Servers used in IR systems now typically have several
GB of main memory, sometimes tens of GB.
Available disk space is several (2–3) orders of
magnitude larger.
Fault tolerance is very expensive: It’s much cheaper
to use many regular machines rather than one fault
tolerant machine.
Introduction to Information Retrieval Sec. 4.1
Hardware basics
Access to data in memory is much faster than access
to data on disk.
Disk seeks: No data is transferred from disk while the
disk head is being positioned.
Therefore: Transferring one large chunk of data from
disk to memory is faster than transferring many small
chunks.
Disk I/O is block-based: Reading and writing of entire
blocks (as opposed to smaller chunks).
Block sizes: 8KB to 256 KB.
Introduction to Information Retrieval Sec. 4.1
Introduction to
Information Retrieval
CS276: Information Retrieval and Web Search
with d1,d2,d3,d5
Postings lists
to be merged Merged
postings list
Disk
Introduction to Information Retrieval Sec. 4.2
SPIMI:
Single-pass in-memory indexing
Key idea 1: Generate separate dictionaries for each
block – no need to maintain term-termID mapping
across blocks.
Key idea 2: Don’t sort. Accumulate postings in
postings lists as they occur.
With these two ideas we can generate a complete
inverted index for each block.
These separate indexes can then be merged into one
big index.
Introduction to Information Retrieval Sec. 4.3
SPIMI-Invert
SPIMI in action
Sorted
Input token Dictionary dictionary
Caesar d1 brutus d1 d3 brutus d1 d3
with d1 caesar d1 d2 d4
Brutus d1 with d1 d2 d3 d5
noble d5
Caesar d2 noble d5
with d1 d2 d3 d5
with d2
Brutus d3 caesar d1 d2 d4
with d3
Caesar d4
noble d5
with d5
23
Introduction to Information Retrieval Sec. 4.3
SPIMI: Compression
Compression makes SPIMI even more efficient.
Compression of terms
Compression of postings
More on this later …
Introduction to
Information Retrieval
CS276: Information Retrieval and Web Search
Distributed indexing
Introduction to Information Retrieval Sec. 4.4
Distributed indexing
For web-scale indexing (don’t try this at home!):
must use a distributed computing cluster
Individual machines are fault-prone
Can unpredictably slow down or fail
How do we exploit such a pool of machines?
Introduction to Information Retrieval Sec. 4.4
Distributed indexing
Maintain a master machine directing the indexing job
– considered “safe”.
Break up indexing into sets of (parallel) tasks.
Master machine assigns each task to an idle machine
from a pool.
Introduction to Information Retrieval Sec. 4.4
Parallel tasks
We will use two sets of parallel tasks
Parsers
Inverters
Break the input document collection into splits
Each split is a subset of documents (corresponding to
blocks in BSBI/SPIMI)
Introduction to Information Retrieval Sec. 4.4
Data flow
assign Master assign
Postings
Parsers
Master assigns a split to an idle parser machine
Parser reads a document at a time and emits
(term, doc) pairs
Parser writes pairs into j partitions
Example: Each partition is for a range of terms’ first
letters
(e.g., a-f, g-p, q-z) – here j = 3.
Now to complete the index inversion
Introduction to Information Retrieval Sec. 4.4
Inverters
An inverter collects all (term,doc) pairs (= postings)
for one term-partition.
Sorts and writes to postings lists
Introduction to Information Retrieval
d1 : C came, C c’ed.
d2 : C died.
→
<C,d1>, <came,d1>, <C,d1>, <c’ed, d1>, <C, d2>, <died,d2>
Reduce:
(<C,(d1,d1,d2)>, <died,(d2)>, <came,(d1)>, <c’ed,(d1)>)
→
(<C,(d1:2,d2:1)><died,(d2:1)>, <came,(d1:1)>,<c’ed,(d1:1)>)
34
Introduction to Information Retrieval Sec. 4.4
Index construction
Index construction was just one phase.
Another phase: transforming a term-partitioned
index into a document-partitioned index.
Term-partitioned: one machine handles a subrange of
terms
Document-partitioned: one machine handles a subrange of
documents
As we’ll discuss in the web part of the course, most
search engines use a document-partitioned index …
better load balancing, etc.
Introduction to Information Retrieval Sec. 4.4
MapReduce
The index construction algorithm we just described is
an instance of MapReduce.
MapReduce (Dean and Ghemawat 2004) is a robust
and conceptually simple framework for distributed
computing …
… without having to write code for the distribution
part.
They describe the Google indexing system (ca. 2002)
as consisting of a number of phases, each
implemented in MapReduce.
Introduction to Information Retrieval Sec. 4.4
Introduction to
Information Retrieval
CS276: Information Retrieval and Web Search
Dynamic indexing
Introduction to Information Retrieval Sec. 4.5
Dynamic indexing
Up to now, we have assumed that collections are
static.
They rarely are:
Documents come in over time and need to be inserted.
Documents are deleted and modified.
This means that the dictionary and postings lists have
to be modified:
Postings updates for terms already in dictionary
New terms added to dictionary
Introduction to Information Retrieval Sec. 4.5
Simplest approach
Maintain “big” main index
New docs go into “small” auxiliary index
Search across both, merge results
Deletions
Invalidation bit-vector for deleted docs
Filter docs output on a search result by this invalidation
bit-vector
Periodically, re-index into one main index
Introduction to Information Retrieval Sec. 4.5
Logarithmic merge
Maintain a series of indexes, each twice as large as
the previous one
At any time, some of these powers of 2 are instantiated
Keep smallest (Z0) in memory
Larger ones (I0, I1, …) on disk
If Z0 gets too big (> n), write to disk as I0
or merge with I0 (if I0 already exists) as Z1
Either write merge Z1 to disk as I1 (if no I1)
Or merge with I1 to form Z2
Introduction to Information Retrieval
≤n Z0 Z0 Z0 Z0
n I0 I0 I0 I0
2n I1 I1 I1 I1
4n I2
8n
16n
43
Introduction to Information Retrieval Sec. 4.5
Introduction to Information Retrieval Sec. 4.5
Logarithmic merge
Auxiliary and main index:
T/n merges where T is # of postings and n is size of auxiliary
Index construction time is O(T2/n) as in the worst case a
posting is touched T/n times
Logarithmic merge: Each posting is merged at most
O(log (T/n)) times, so complexity is O(T log (T/n))
So logarithmic merge is much more efficient for index
construction
But query processing now requires the merging of
O(log (T/n)) indexes
Whereas it is O(1) if you just have a main and auxiliary index
Introduction to Information Retrieval Sec. 4.5
48
Introduction to Information Retrieval