

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Inverted Index
incomplete
2: Use the Index
incomplete
3: Boolean Search
incomplete
4: Term Frequency
incomplete
5: Inverse Document Frequency (IDF)
incomplete
6: TF-IDF
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Boolean search combines keyword matches with operations like AND, OR, and NOT. For example:
Remember, thanks to our inverted index, each of these words maps to a set of document IDs:
bear → [1, 3, 5, 7, 9]wizard → [2, 4, 6, 8]terror → [7, 9]cyborg → [2, 6]So each boolean operation is really just a set operation on those document IDs:
These operations are fast because we're working with sets of numbers, not large text documents.
bear AND forest finds documents that contain both terms:
bear: [1] [3] [5] [7] [9]
forest: [1] [4] [5] [8]
AND: [1] [5] # Only overlapping documents
bear OR cyborg finds documents that contain either term:
bear: [1] [3] [5] [7] [9]
cyborg: [2] [6]
OR: [1] [2] [3] [5] [6] [7] [9] # All documents combined
bear NOT terror finds documents with bear, then excludes documents with terror:
bear: [1] [3] [5] [7] [9]
terror: [7] [9]
NOT: [1] [3] [5] # Bear docs minus terror docs
We aren't going to implement boolean operations by hand, since it's a lot of code that we'd quickly overwrite with more advanced techniques in the next chapter.