Indexing UCSB 293S, 2017 Mainly based on slides from the text books of Croft/Metzler/Strohman and Manning/Raghavan/Schutze All slides ©Addison Wesley,

Slides:



Advertisements
Similar presentations
Information Retrieval in Practice
Advertisements

Ranking with Index Rong Jin.
Copyright 2003Curt Hill Hash indexes Are they better or worse than a B+Tree?
PrasadL07IndexCompression1 Index Compression Adapted from Lectures by Prabhakar Raghavan (Yahoo, Stanford) and Christopher Manning.
CpSc 881: Information Retrieval. 2 Why compression? (in general) Use less disk space (saves money) Keep more stuff in memory (increases speed) Increase.
Hinrich Schütze and Christina Lioma Lecture 5: Index Compression
Inverted Index Hongning Wang
Information Retrieval in Practice
Indexing UCSB 290N. Mainly based on slides from the text books of Croft/Metzler/Strohman and Manning/Raghavan/Schutze All slides ©Addison Wesley, 2008.
CPSC 231 Organizing Files for Performance (D.H.) 1 LEARNING OBJECTIVES Data compression. Reclaiming space in files. Compaction. Searching. Sorting, Keysorting.
Inverted Indices. Inverted Files Definition: an inverted file is a word-oriented mechanism for indexing a text collection in order to speed up the searching.
CS336: Intelligent Information Retrieval
Information Retrieval IR 4. Plan This time: Index construction.
Introduction to Information Retrieval Introduction to Information Retrieval Hinrich Schütze and Christina Lioma Lecture 5: Index Compression 1.
Indexing Debapriyo Majumdar Information Retrieval – Spring 2015 Indian Statistical Institute Kolkata.
Chapter 2 Architecture of a Search Engine. Search Engine Architecture n A software architecture consists of software components, the interfaces provided.
Recap Preprocessing to form the term vocabulary Documents Tokenization token and term Normalization Case-folding Lemmatization Stemming Thesauri Stop words.
Indices Tomasz Bartoszewski. Inverted Index Search Construction Compression.
March 16 & 21, Csci 2111: Data and File Structures Week 9, Lectures 1 & 2 Indexed Sequential File Access and Prefix B+ Trees.
Search - on the Web and Locally Related directly to Web Search Engines: Part 1 and Part 2. IEEE Computer. June & August 2006.
The College of Saint Rose CSC 460 / CIS 560 – Search and Information Retrieval David Goldschmidt, Ph.D. from Search Engines: Information Retrieval in Practice,
Author: Abhishek Das Google Inc., USA Ankit Jain Google Inc., USA Presented By: Anamika Mukherji 13/26/2013Indexing The World Wide Web.
Search Engines. Search Strategies Define the search topic(s) and break it down into its component parts What terms, words or phrases do you use to describe.
The College of Saint Rose CSC 460 / CIS 560 – Search and Information Retrieval David Goldschmidt, Ph.D. from Search Engines: Information Retrieval in Practice,
Hash Table March COP 3502, UCF 1. Outline Hash Table: – Motivation – Direct Access Table – Hash Table Solutions for Collision Problem: – Open.
Chapter 5 Ranking with Indexes 1. 2 More Indexing Techniques n Indexing techniques:  Inverted files - best choice for most applications  Suffix trees.
Evidence from Content INST 734 Module 2 Doug Oard.
Introduction to Information Retrieval Introduction to Information Retrieval Lecture 4: Index Construction Related to Chapter 4:
Chapter 5 Record Storage and Primary File Organizations
Query processing: optimizations Paolo Ferragina Dipartimento di Informatica Università di Pisa Reading 2.3.
Search Engines Information Retrieval in Practice All slides ©Addison Wesley, 2008 Annotations by Michael L. Nelson.
1. 2 Today’s Agenda Search engines: What are the main challenges in building a search engine? Structure of the data index Naïve solutions and their problems.
Chapter 5 Ranking with Indexes. Indexes and Ranking n Indexes are designed to support search  Faster response time, supports updates n Text search engines.
Information Retrieval Inverted Files.. Document Vectors as Points on a Surface Normalize all document vectors to be of length 1 Define d' = Then the ends.
DS.H.1 Hashing Chapter 5 Overview The General Idea Hash Functions Separate Chaining Open Addressing Rehashing Extendible Hashing Application Example: Geometric.
Information Retrieval in Practice
University of Maryland Baltimore County
Why indexing? For efficient searching of a document
COMP9319: Web Data Compression and Search
Large Scale Search: Inverted Index, etc.
Information Retrieval in Practice
CPSC 231 Organizing Files for Performance (D.H.)
Text Indexing and Search
CHP - 9 File Structures.
Query processing: phrase queries and positional indexes
Indexing & querying text
Information Retrieval in Practice
Modified from Stanford CS276 slides Lecture 4: Index Construction
Lecture 7: Index Construction
Are they better or worse than a B+Tree?
Implementation Issues & IR Systems
13 Text Processing Hongfei Yan June 1, 2016.
Database Implementation Issues
File organization and Indexing
Disk storage Index structures for files
Hash Tables.
Lecture 7: Index Construction
Lectures 4: Skip Pointers, Phrase Queries, Positional Indexing
DATABASE IMPLEMENTATION ISSUES
Lecture 5: Index Compression Hankz Hankui Zhuo
3-3. Index compression Most slides were adapted from Stanford CS 276 course and University of Munich IR course.
Indexing 4/11/2019.
Query processing: phrase queries and positional indexes
Database Implementation Issues
INF 141: Information Retrieval
Advance Database System
CSE 326: Data Structures Lecture #14
Database Implementation Issues
Index Structures Chapter 13 of GUW September 16, 2019
Presentation transcript:

Indexing UCSB 293S, 2017 Mainly based on slides from the text books of Croft/Metzler/Strohman and Manning/Raghavan/Schutze All slides ©Addison Wesley, 2008

Table of Content Inverted index with positional information Compression Distributed indexing

Indexing Process

Indexes Indexes are data structures designed to make search faster Most common data structure is inverted index general name for a class of structures “inverted” because documents are associated with words, rather than words with documents similar to a concordance What is a reasonable abstract model for ranking? enables discussion of indexes without details of retrieval model

Simple Model of Ranking

More Concrete Model

Inverted Index Each index term is associated with an inverted list Contains lists of documents, or lists of word occurrences in documents, and other information Each entry is called a posting The part of the posting that refers to a specific document or location is called a pointer Each document in the collection is given a unique number Lists are usually document-ordered (sorted by document number)

Example “Collection”

Simple Inverted Index

supports better ranking algorithms Inverted Index with counts supports better ranking algorithms

Proximity Matches Matching phrases or words within a window explicitly or implicitly. e.g., "tropical fish", or “find tropical within 5 words of fish” Word positions in inverted lists make these types of query features efficient e.g.,

Positional indexes Store, for each term, entries of the form: <number of docs containing term; doc1: position1, position2 … ; doc2: position1, position2 … ; etc.>

Positional index example <be: 993427; 1: 7, 18, 33, 72, 86, 231; 2: 3, 149; 4: 17, 191, 291, 430, 434; 5: 363, 367, …> Which of docs 1,2,4,5 could contain “to be or not to be”? this expands postings storage substantially

Inverted Index with positions supports proximity matches

Fields and Extents Document structure is useful in search field restrictions e.g., date, from:, etc. some fields more important e.g., title Options: separate inverted lists for each field type add information about fields to postings use extent lists to mark special areas in a document

Extent Lists An extent is a contiguous region of a document represent extents using word positions inverted list records all extents for a given field type e.g. 1:(1,3)  title in document 1 is from 1 to 3 extent list

Other Issues Precomputed scores in inverted list e.g., list for “fish” [(1:3.6), (3:2.2)], where 3.6 is total feature value for document 1 improves speed but reduces flexibility Score-ordered lists query processing engine can focus only on the top part of each inverted list, where the highest-scoring documents are recorded very efficient for single-word queries

Zipf’s law on term distribution study the relative frequencies of terms. there are a few very frequent terms and very many rare terms. Zipf’s law: The i-th most frequent term has frequency proportional to 1/i . cfi is collection frequency: the number of occurrences of the term ti cfi ∝ 1/i = c/i where c is a normalizing constant log(cfi )+ log(i) = log(c) Heaps’ Law gives the vocabulary size in collections. Zipf’s law: 2nd most frequent term occurs half as often as the most frequent term. (Is the distribution similar in both the document and the collection in practice?)

Zipf distribution for search query traffic

Analyze index size with Zipf distribution Number of docs = n = 40M Number of terms = m = 1M Use Zipf to estimate number of postings entries: n + n/2 + n/3 + …. + n/m ~ n ln m = 560M entries 16-byte (4+8+4) records (term, doc, freq). 9GB No positional info yet Check for yourself

Positional index size Need an entry for each occurrence, not just once per document Index size depends on average document size Average web page has <1000 terms SEC filings, PDF files, … easily 100,000 terms Consider a term with frequency 0.1% in a doc 100 1 100,000 1000 Positional postings Postings Document size

Compression Inverted lists are very large Much higher if n-grams are indexed Compression of indexes saves disk and/or memory space Typically have to decompress lists to use them Best compression techniques have good compression ratios and are easy to decompress Lossless compression – no information lost

Rules of thumb Positional index size factor of 2-4 over non-positional index Positional index size 35-50% of volume of original text Caveat: all of this holds for “English-like” languages

Compression Basic idea: Common data elements use short codes while uncommon data elements use longer codes Example: coding numbers number sequence: 0, 1, 0, 2,0,3,0 Possible binary encoding: Store 0 with a single 0: 0 01 0 10 0 11 0 How about this: 0 1 0 10 0 11 0 Can you convert back to 0, 1, 0, 2, 0, 3, 0?

Compression Example Ambiguous encoding – not clear how to decode another decoding: which represents: unambiguous code: which gives: Small numbers  use a small number of bits

Delta Encoding Word count data is good candidate for compression many small numbers and few larger numbers encode small numbers with small codes Document numbers are less predictable but differences between numbers in an ordered list are smaller and more predictable Delta encoding: encoding differences between document numbers (d-gaps)

Delta Encoding Inverted list (without counts) Differences between adjacent numbers Differences for a high-frequency word are easier to compress, e.g., Differences for a low-frequency word are large, e.g.,

Bit-Aligned Codes Breaks between encoded numbers can occur after any bit position Unary code Encode k by k 1s followed by 0 0 at end makes code unambiguous

Unary and Binary Codes Unary is very efficient for small numbers such as 0 and 1, but quickly becomes very expensive 1023 can be represented in 10 binary bits, but requires 1024 bits in unary Binary is more efficient for large numbers, but it may be ambiguous

Elias-γ Code To encode a number k, compute kd is number of binary digits, encoded in unary

Elias-δ Code Elias-γ code uses no more bits than unary, many fewer for k > 2 1023 takes 19 bits instead of 1024 bits using unary In general, takes 2⌊log2k⌋+1 bits To improve coding of large numbers, use Elias-δ code Instead of encoding kd in unary, we encode kd + 1 using Elias-γ Takes approximately 2 log2 log2 k + log2 k bits

Elias-δ Code Split kd into: encode kdd in unary, kdr in binary, and kr in binary

Byte-Aligned Codes Variable-length bit encodings can be a problem on processors that process bytes v-byte is a popular byte-aligned code Similar to Unicode UTF-8 Shortest v-byte code is 1 byte Numbers are 1 to 4 bytes, with high bit 1 in the last byte, 0 otherwise

V-Byte Encoding

V-Byte Encoder

V-Byte Decoder

Compression Example Consider invert list with positions: Delta encode document numbers and positions: Compress using v-byte:

Word-Aligned Simple-9 Code (Anh/Moffat 2004) Try to pack several numbers into one word (32 bits) each word has 4 control bits and 28 data bits Assume each number requires at most 28 bits. Data represented by 28 bits: - 1 28-bit number - 2 14-bit numbers - 3 9-bit numbers (1 bit wasted) - 4 7-bit numbers - 5 5-bit numbers (3 bits wasted) - 7 4-bit numbers - 9 3-bit numbers (1 bit wasted) - 14 2-bit numbers - 28 1-bit numbers 4 Control bits indicate which of these 9 cases is used

Word-Aligned Simple-9 Code (Anh/Moffat 2004) Algorithm: do the next 28 numbers fit into one bit each? if no: do the next 14 numbers fit into 2 bits each? if no: do the next 9 numbers fit into 3 bits each? … Fast decoding: only one if-decision for every 32 bits Decent compression: can use < 1 byte for small numbers

Compression Performance [WWW08, Zhang/Long/Suel]

Skip pointers for faster merging of postings

Basic merge Walk through the two postings simultaneously, in time linear in the total number of postings entries 2 4 8 16 32 64 128 Brutus Caesar 2 8 1 2 3 5 8 17 21 31 If the list lengths are m and n, the merge takes O(m+n) operations. Can we do better? Yes, if index isn’t changing too fast.

Augment postings with skip pointers (at indexing time) 16 128 128 2 4 8 16 32 64 8 31 31 1 2 3 5 8 17 21 Why? To skip postings that will not be part of the search results.

Query processing with skip pointers 16 128 When we get to 16 on the top list, we see that its successor is 32. 128 2 4 8 16 32 64 8 31 But the skip successor of 8 on the lower list is 31, so we can skip ahead past the intervening postings. 31 1 2 3 5 8 17 21 Suppose we’ve stepped through the lists until we process 8 on each list.

Skip Pointers A skip pointer (d, p) contains a document number d and a byte (or bit) position p Means there is an inverted list posting that starts at position p, and the posting before it was for document d Inverted list skip pointers

Skip Pointers Example Inverted list D-gaps Skip pointers

Where do we place skips? Tradeoff: More skips  shorter skip spans  more likely to skip. But lots of comparisons to skip pointers. Fewer skips  few pointer comparison, but then long skip spans  few successful skips.

Placing skips Simple heuristic: for postings of length L, use sqrt(L) evenly-spaced skip pointers. This ignores the distribution of query terms. Easy if the index is relatively static; harder if L keeps changing because of updates.

Auxiliary Structures Inverted lists usually stored together in a single file for efficiency Inverted file Vocabulary or lexicon Contains a lookup table from index terms to the byte offset of the inverted list in the inverted file Either hash table in memory or B-tree for larger vocabularies Term statistics stored at start of inverted lists Collection statistics stored in separate file

Distributed Indexing Distributed processing driven by need to index and analyze huge amounts of data (i.e., the Web) Large numbers of inexpensive servers used rather than larger, more expensive machines MapReduce is a distributed programming tool designed for indexing and analysis tasks

MapReduce Distributed programming framework that focuses on data placement and distribution Mapper Generally, transforms a list of items into another list of items of the same length Reducer Transforms a list of items into a single item Definitions not so strict in terms of number of outputs Many mapper and reducer tasks on a cluster of machines

MapReduce

MapReduce Basic process Map stage which transforms data records into pairs, each with a key and a value Shuffle uses a hash function so that all pairs with the same key end up next to each other and on the same machine Reduce stage processes records in batches, where all pairs with the same key are processed at the same time Idempotence of Mapper and Reducer provides fault tolerance multiple operations on same input gives same output

Indexing Example