66
boolean queries Inverted index query processing Query optimization boolean model September 9, 2018 1 / 37

boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

  • Upload
    others

  • View
    36

  • Download
    3

Embed Size (px)

Citation preview

Page 1: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

boolean model

September 9, 2018

1 / 37

Page 2: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Outline

1 boolean queries

2 Inverted index

3 query processing

4 Query optimization

2 / 37

Page 3: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

taxonomy of IR models

Document Property

text

links

multimedia

IR models

Boolean

vector

probalistic

Semistructured text

proximal nodes

xml based

web

page rank

hubs and authorities (HITs)

Multimedia

image retrieval

audio

video

Set theoretic

fuzzy

extended boolean

set-based

algebraic

generalized vector

LSI

NN

probablistic

BM25

language models

Bayersian networks

3 / 37

Page 4: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Outline

1 boolean queries

2 Inverted index

3 query processing

4 Query optimization

4 / 37

Page 5: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Boolean retrieval

The Boolean model: the simplest model for an informationretrieval system.

Queries are Boolean expressions, e.g.,

Caesar and Brutus

The search engine returns all documents that satisfy theBoolean expression.

Does Google use the Boolean model?

5 / 37

Page 6: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Boolean retrieval

The Boolean model: the simplest model for an informationretrieval system.

Queries are Boolean expressions, e.g.,

Caesar and Brutus

The search engine returns all documents that satisfy theBoolean expression.

Does Google use the Boolean model?

5 / 37

Page 7: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Does Google use the Boolean model?

Not a simple yes or no question.

On Google, the default interpretation of a queryw1 w2 . . . wn

isw1 AND w2 AND . . . AND wn

Cases where you get hits that do not contain one of the wi?

6 / 37

Page 8: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Does Google use the Boolean model?

Not a simple yes or no question.

On Google, the default interpretation of a queryw1 w2 . . . wn

isw1 AND w2 AND . . . AND wn

Cases where you get hits that do not contain one of the wi?

6 / 37

Page 9: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Cases that are not exact boolean query

anchor text

page contains variant of wi (morphology, spelling correction,synonym)

long queries (n large)

boolean expression generates very few hits

...

7 / 37

Page 10: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Cases that are not exact boolean query

anchor text

page contains variant of wi (morphology, spelling correction,synonym)

long queries (n large)

boolean expression generates very few hits

...

7 / 37

Page 11: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Cases that are not exact boolean query

anchor text

page contains variant of wi (morphology, spelling correction,synonym)

long queries (n large)

boolean expression generates very few hits

...

7 / 37

Page 12: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Cases that are not exact boolean query

anchor text

page contains variant of wi (morphology, spelling correction,synonym)

long queries (n large)

boolean expression generates very few hits

...

7 / 37

Page 13: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Cases that are not exact boolean query

anchor text

page contains variant of wi (morphology, spelling correction,synonym)

long queries (n large)

boolean expression generates very few hits

...

7 / 37

Page 14: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Simple Boolean vs. Ranking of result set

Simple Boolean retrieval returns matching documents in noparticular order.

Google (and others) ranks the result set

they rank good hits (according to some estimator of relevance)higher than bad hits.

8 / 37

Page 15: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Outline

1 boolean queries

2 Inverted index

3 query processing

4 Query optimization

9 / 37

Page 16: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Unstructured data in 1650

Which plays of Shakespeare contain the words Brutus andCaesar, but not Calpurnia?

One could grep all of Shakespeare’s plays for Brutus andCaesar, then strip out lines containing Calpurnia.

Why is grep not the solution?

Slow (for large collections)grep is line-oriented, IR is document-oriented“not Calpurnia” is non-trivialOther operations (e.g., find the word Romans nearcountryman) not feasible

10 / 37

Page 17: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Unstructured data in 1650

Which plays of Shakespeare contain the words Brutus andCaesar, but not Calpurnia?

One could grep all of Shakespeare’s plays for Brutus andCaesar, then strip out lines containing Calpurnia.

Why is grep not the solution?

Slow (for large collections)grep is line-oriented, IR is document-oriented“not Calpurnia” is non-trivialOther operations (e.g., find the word Romans nearcountryman) not feasible

10 / 37

Page 18: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Term-document incidence matrix

Anthony Julius The Hamlet Othello Macbeth . . .and Caesar Tempest

CleopatraAnthony 1 1 0 0 0 1Brutus 1 1 0 1 0 0Caesar 1 1 0 1 1 1Calpurnia 0 1 0 0 0 0Cleopatra 1 0 0 0 0 0mercy 1 0 1 1 1 1worser 1 0 1 1 1 0. . .Entry is 1 if term occurs. Example: Calpurnia occurs in Julius Caesar.Entry is 0 if term doesn’t occur. Example: Calpurnia doesn’t occur in Thetempest.

11 / 37

Page 19: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Term-document incidence matrix

Anthony Julius The Hamlet Othello Macbeth . . .and Caesar Tempest

CleopatraAnthony 1 1 0 0 0 1Brutus 1 1 0 1 0 0Caesar 1 1 0 1 1 1Calpurnia 0 1 0 0 0 0Cleopatra 1 0 0 0 0 0mercy 1 0 1 1 1 1worser 1 0 1 1 1 0. . .Entry is 1 if term occurs. Example: Calpurnia occurs in Julius Caesar.Entry is 0 if term doesn’t occur. Example: Calpurnia doesn’t occur in Thetempest.

11 / 37

Page 20: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Term-document incidence matrix

Anthony Julius The Hamlet Othello Macbeth . . .and Caesar Tempest

CleopatraAnthony 1 1 0 0 0 1Brutus 1 1 0 1 0 0Caesar 1 1 0 1 1 1Calpurnia 0 1 0 0 0 0Cleopatra 1 0 0 0 0 0mercy 1 0 1 1 1 1worser 1 0 1 1 1 0. . .Entry is 1 if term occurs. Example: Calpurnia occurs in Julius Caesar.Entry is 0 if term doesn’t occur. Example: Calpurnia doesn’t occur in Thetempest.

11 / 37

Page 21: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Incidence vectors

So we have a 0/1 vector for each term.

To answer the query Brutusand Caesar and notCalpurnia:

Take the vectors for Brutus, Caesar, and CalpurniaComplement the vector of CalpurniaDo a (bitwise) and on the three vectors

Brutus 1 1 0 1 0 0Caesar 1 1 0 1 1 1not Calpurnia 1 0 1 1 1 1

AND 1 0 0 1 0 0

12 / 37

Page 22: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

0/1 vectors and result of bitwise operations

Anthony Julius The Hamlet Othello Macbeth . . .and Caesar Tempest

CleopatraAnthony 1 1 0 0 0 1Brutus 1 1 0 1 0 0Caesar 1 1 0 1 1 1Calpurnia 0 1 0 0 0 0Cleopatra 1 0 0 0 0 0mercy 1 0 1 1 1 1worser 1 0 1 1 1 0. . .

result: 1 0 0 1 0 0

13 / 37

Page 23: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Answers to query

Anthony and Cleopatra, Act III, Scene iiAgrippa [Aside to Domitius Enobarbus]: Why, Enobarbus,

When Antony found Julius Caesar dead,He cried almost to roaring; and he weptWhen at Philippi he found Brutus slain.

Hamlet, Act III, Scene iiLord Polonius: I did enact Julius Caesar: I was killed i’ the

Capitol; Brutus killed me.

14 / 37

Page 24: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Bigger collections

Consider N = 106 documents, each with about 1000 tokens

⇒ total of 109 tokens

On average 6 bytes per token, including spaces andpunctuation ⇒ size of document collection is about 6 · 109 =6 GB

Assume there are M = 500,000 distinct terms in the collection

(Notice that we are making a term/token distinction.)

15 / 37

Page 25: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Can’t build the incidence matrix

M = 500, 000× 106 = half a trillion 0s and 1s.

But the matrix has no more than one billion 1s.

Matrix is extremely sparse.

What is a better representations?

We only record the 1s.

16 / 37

Page 26: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Can’t build the incidence matrix

M = 500, 000× 106 = half a trillion 0s and 1s.

But the matrix has no more than one billion 1s.

Matrix is extremely sparse.

What is a better representations?

We only record the 1s.

16 / 37

Page 27: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Inverted Index

For each term t, we store a list of all documents that contain t.

Brutus −→ 1 2 4 11 31 45 173 174

Caesar −→ 1 2 4 5 6 16 57 132 . . .

Calpurnia −→ 2 31 54 101

...︸ ︷︷ ︸ ︸ ︷︷ ︸dictionary postings

17 / 37

Page 28: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Inverted Index

For each term t, we store a list of all documents that contain t.

Brutus −→ 1 2 4 11 31 45 173 174

Caesar −→ 1 2 4 5 6 16 57 132 . . .

Calpurnia −→ 2 31 54 101

...︸ ︷︷ ︸ ︸ ︷︷ ︸dictionary postings

17 / 37

Page 29: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Inverted Index

For each term t, we store a list of all documents that contain t.

Brutus −→ 1 2 4 11 31 45 173 174

Caesar −→ 1 2 4 5 6 16 57 132 . . .

Calpurnia −→ 2 31 54 101

...︸ ︷︷ ︸ ︸ ︷︷ ︸dictionary postings

17 / 37

Page 30: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Inverted index construction

1 Collect the documents to be indexed:Friends, Romans, countrymen. So let it be with Caesar . . .

2 Tokenize the text, turning each document into a list of tokens:

Friends Romans countrymen So . . .

3 Do linguistic preprocessing, producing a list of normalizedtokens, which are the indexing terms:

friend roman countryman so . . .

4 Index the documents that each term occurs in by creating aninverted index, consisting of a dictionary and postings.

18 / 37

Page 31: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Tokenization and preprocessingDoc 1. I did enact Julius Caesar: Iwas killed i’ the Capitol; Brutus killedme.Doc 2. So let it be with Caesar. Thenoble Brutus hath told you Caesarwas ambitious:

=⇒Doc 1. i did enact julius caesar i waskilled i’ the capitol brutus killed meDoc 2. so let it be with caesar thenoble brutus hath told you caesar wasambitious

19 / 37

Page 32: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Generate postings

Doc 1. i did enact julius caesar i waskilled i’ the capitol brutus killed meDoc 2. so let it be with caesar thenoble brutus hath told you caesar wasambitious

=⇒

term docIDi 1did 1enact 1julius 1caesar 1i 1was 1killed 1i’ 1the 1capitol 1brutus 1killed 1me 1so 2let 2it 2be 2with 2caesar 2the 2noble 2brutus 2hath 2told 2you 2caesar 2was 2ambitious 2

20 / 37

Page 33: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Sort postingsterm docIDi 1did 1enact 1julius 1caesar 1i 1was 1killed 1i’ 1the 1capitol 1brutus 1killed 1me 1so 2let 2it 2be 2with 2caesar 2the 2noble 2brutus 2hath 2told 2you 2caesar 2was 2ambitious 2

=⇒

term docIDambitious 2be 2brutus 1brutus 2capitol 1caesar 1caesar 2caesar 2did 1enact 1hath 1i 1i 1i’ 1it 2julius 1killed 1killed 1let 2me 1noble 2so 2the 1the 2told 2you 2was 1was 2with 2

21 / 37

Page 34: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Create postings lists, determine document frequencyterm docIDambitious 2be 2brutus 1brutus 2capitol 1caesar 1caesar 2caesar 2did 1enact 1hath 1i 1i 1i’ 1it 2julius 1killed 1killed 1let 2me 1noble 2so 2the 1the 2told 2you 2was 1was 2with 2

=⇒

term doc. freq. → postings lists

ambitious 1 → 2

be 1 → 2

brutus 2 → 1 → 2

capitol 1 → 1

caesar 2 → 1 → 2

did 1 → 1

enact 1 → 1

hath 1 → 2

i 1 → 1

i’ 1 → 1

it 1 → 2

julius 1 → 1

killed 1 → 1

let 1 → 2

me 1 → 1

noble 1 → 2

so 1 → 2

the 2 → 1 → 2

told 1 → 2

you 1 → 2

was 2 → 1 → 2

with 1 → 2

22 / 37

Page 35: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Split the result into dictionary and postings file

Brutus −→ 1 2 4 11 31 45 173 174

Caesar −→ 1 2 4 5 6 16 57 132 . . .

Calpurnia −→ 2 31 54 101

...︸ ︷︷ ︸ ︸ ︷︷ ︸dictionary postings file

23 / 37

Page 36: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Outline

1 boolean queries

2 Inverted index

3 query processing

4 Query optimization

24 / 37

Page 37: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Simple conjunctive query (two terms)

Consider the query: Brutus AND Calpurnia

To find all matching documents using inverted index:1 Locate Brutus in the dictionary2 Retrieve its postings list from the postings file3 Locate Calpurnia in the dictionary4 Retrieve its postings list from the postings file5 Intersect the two postings lists6 Return intersection to user

25 / 37

Page 38: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒

2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 39: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒

2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 40: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒

2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 41: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2

→ 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 42: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2

→ 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 43: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2

→ 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 44: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2

→ 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 45: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 46: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 47: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 48: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 49: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 50: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 51: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Intersection =⇒ 2 → 31

This is linear in the length of the postings lists.

Note: This only works if postings lists are sorted.

26 / 37

Page 52: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Intersecting two postings lists

Intersect(p1, p2)1 answer ← 〈 〉2 while p1 6= nil and p2 6= nil3 do if docID(p1) = docID(p2)4 then Add(answer , docID(p1))5 p1 ← next(p1)6 p2 ← next(p2)7 else if docID(p1) < docID(p2)8 then p1 ← next(p1)9 else p2 ← next(p2)

10 return answer

Question: can we make it faster?

27 / 37

Page 53: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Query processing: Exercise

france −→ 1 → 2 → 3 → 4 → 5 → 7 → 8 → 9 → 11 → 12 → 13 → 14 → 15

paris −→ 2 → 6 → 10 → 12 → 14

lear −→ 12 → 15

Compute hit list for ((paris AND NOT france) OR lear)

28 / 37

Page 54: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Boolean retrieval model: Assessment

The Boolean retrieval model can answer any query that is aBoolean expression.

Boolean queries are queries that use and, or and not to joinquery terms.Views each document as a set of terms.Is precise: Document matches condition or not.

Primary commercial retrieval tool for 3 decades

Many professional searchers (e.g., lawyers) still like Booleanqueries.

You know exactly what you are getting.

Many search systems you use are also Boolean: spotlight,email, intranet etc.

29 / 37

Page 55: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Outline

1 boolean queries

2 Inverted index

3 query processing

4 Query optimization

30 / 37

Page 56: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Query optimization

Consider a query that is an and of n terms, n > 2

For each of the terms, get its postings list, then and themtogether

Example query: Brutus AND Calpurnia AND Caesar

What is the best order for processing this query?

31 / 37

Page 57: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Query optimization

Example query: Brutus AND Calpurnia AND Caesar

Simple and effective optimization: Process in order ofincreasing frequency

Start with the shortest postings list, then keep cutting further

In this example, first Caesar, then Calpurnia, thenBrutus

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Caesar −→ 5 → 31

32 / 37

Page 58: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Query optimization

Example query: Brutus AND Calpurnia AND Caesar

Simple and effective optimization: Process in order ofincreasing frequency

Start with the shortest postings list, then keep cutting further

In this example, first Caesar, then Calpurnia, thenBrutus

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Caesar −→ 5 → 31

32 / 37

Page 59: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Query optimization

Example query: Brutus AND Calpurnia AND Caesar

Simple and effective optimization: Process in order ofincreasing frequency

Start with the shortest postings list, then keep cutting further

In this example, first Caesar, then Calpurnia, thenBrutus

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Caesar −→ 5 → 31

32 / 37

Page 60: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Query optimization

Example query: Brutus AND Calpurnia AND Caesar

Simple and effective optimization: Process in order ofincreasing frequency

Start with the shortest postings list, then keep cutting further

In this example, first Caesar, then Calpurnia, thenBrutus

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Caesar −→ 5 → 31

32 / 37

Page 61: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Query optimization

Example query: Brutus AND Calpurnia AND Caesar

Simple and effective optimization: Process in order ofincreasing frequency

Start with the shortest postings list, then keep cutting further

In this example, first Caesar, then Calpurnia, thenBrutus

Brutus −→ 1 → 2 → 4 → 11 → 31 → 45 → 173 → 174

Calpurnia −→ 2 → 31 → 54 → 101

Caesar −→ 5 → 31

32 / 37

Page 62: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Optimized intersection algorithm for conjunctive queries

Intersect(〈t1, . . . , tn〉)1 terms ← SortByIncreasingFrequency(〈t1, . . . , tn〉)2 result ← postings(first(terms))3 terms ← rest(terms)4 while terms 6= nil and result 6= nil5 do result ← Intersect(result, postings(first(terms)))6 terms ← rest(terms)7 return result

33 / 37

Page 63: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

More general optimization

Example query: (madding or crowd) and (ignoble orstrife)

Get frequencies for all terms

Estimate the size of each or by the sum of its frequencies(conservative)

Process in increasing order of or sizes

34 / 37

Page 64: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

Advantages and disadvantages of Boolean Model

Advantages:

Easy for the system

Users get transparency: it is easy to understand why adocument was or was not retrieved

Users get control: it easy to determine whether the query istoo specific (few results) or too broad (many results)

Disadvantages:

The burden is on the user to formulate a good boolean query

35 / 37

Page 65: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

search engine envisioned in 1945

Vannevar Bush described in his 1945 The Atlantic Monthly article”As We May Think”.

36 / 37

Page 66: boolean model - University of Windsorjlu.myweb.cs.uwindsor.ca/538/538boolean2018.pdf · Boolean retrieval The Boolean model: the simplest model for an information retrieval system

boolean queriesInverted index

query processingQuery optimization

The memex (memory extender) is the name of thehypothetical proto-hypertext system

Bush envisioned the memex as a device in which individualswould compress and store all of their books, records, andcommunications,

”mechanized so that it may be consulted with exceedingspeed and flexibility.”

The memex would provide an ”enlarged intimate supplementto one’s memory”.

The concept of the memex influenced the development ofearly hypertext systems (eventually leading to the creation ofthe World Wide Web).

used a form of document bookmark list, of static microfilmpages, rather than a true hypertext system where parts ofpages would have internal structure beyond the commontextual format.

37 / 37