Yash's Site

Search Engines

Workshop | Build a Reverse Index

yash101

Published 2/7/2025

Updated 2/7/2025

In this part, you will use an interactive IDE in your browser to implement your own index and query functions on a reverse index. Part 4 will have the working solution.

Below is an editor. The search and index functions are unimplemented. Try to implement both functions and get the search engine working. The driver code in this workshop will download Æsop’s Fables as a JSON, attempt to index your code, and attempt to search a few queries.

#

✅ Expected output

Query:  wolf  results:  24
Hits:  2  document:  The Kid and the Wolf
Hits:  2  document:  The Wolf and the Lion
Hits:  1  document:  The Wolf And The Lamb
Hits:  1  document:  The Kingdom of the Lion
Hits:  1  document:  The Wolf and the Crane
 
Query:  cat  results:  6
Hits:  1  document:  The Cat and the Cock
Hits:  1  document:  The Cat and the Birds
Hits:  1  document:  The Mice in Council
Hits:  1  document:  The Cat and the Mice
Hits:  1  document:  The Eagle, the Cat, and the Wild Sow
 
Query:  dog jumped over wolf and fox  results:  298
Hits:  5  document:  The Fox and the Monkey
Hits:  5  document:  The Kid and the Wolf
Hits:  4  document:  The Lion, the Wolf, and the Fox
Hits:  4  document:  The Wolf and the Lion
Hits:  4  document:  The Fox and the Lion
 
Query:  cat at the mouse then the dog barked at the cat  results:  306
Hits:  4  document:  The Wolf and the Lion
Hits:  3  document:  The Cat and the Birds
Hits:  3  document:  The Mice in Council
Hits:  3  document:  The Cat and the Mice
Hits:  3  document:  The Eagle, the Cat, and the Wild Sow
#

A view of aesop-fables.json

#

🥽 Experimentation

  1. Try editing the preprocessing
  2. Try editing the tokenize function
  3. Try printing parts of your index to inspect it
  4. Are there any anomalies in the index?
  5. Try different search queries
#

⏭️ Next Page

The next page has a working solution for the workshop.