Exercise 1: The Inverted Index, the Book-Index Analogy, and the Worked Example — Possible Solution ==================================================================== WHAT AN INVERTED INDEX IS, USING THE BOOK-INDEX ANALOGY ------------------------------ Per this chapter, "a 'forward' index maps a document to its own content — the way a book's table of contents maps a chapter to a page. An inverted index does the opposite: it maps each individual term to the list of documents containing it — exactly like a book's own back-of-book index, mapping a word to the page numbers it appears on." A book's table of contents lets you look up "Chapter 3" and find out it starts on page 45 — going FROM a known chapter TO its location. A book's own back-of-book index works the opposite direction: given a specific WORD (say, "photosynthesis"), it tells you every page number that word appears on — going FROM a term TO its locations. An inverted index in a search engine works exactly like that back-of-book index: given a search term, it directly returns every document containing that term, rather than requiring a scan through every document to check. WALKING THROUGH THE WORKED EXAMPLE ------------------------------ Per this chapter, indexing "the quick brown fox" (doc 1) and "the lazy dog" (doc 2) produces: the -> [doc 1, doc 2] quick -> [doc 1] brown -> [doc 1] fox -> [doc 1] lazy -> [doc 2] dog -> [doc 2] Each unique term across both documents becomes its own entry (its own "row," in a loose sense) in this structure. The word "the" appears in BOTH documents, so its entry lists both doc 1 and doc 2. Each of the other words ("quick," "brown," "fox," "lazy," "dog") appears in only ONE of the two documents, so each of their entries lists just that one document. A search for "fox" is then answered by directly looking up the "fox" entry in this table, immediately returning [doc 1] — no scanning of either document's actual raw text was required to answer the query. WHY THIS WORKS AS AN ANSWER ------------------------------ It states the book-index analogy precisely, contrasting it against the forward-index/table-of-contents comparison the chapter also makes, and walks through the worked example term by term, explaining specifically why "the" ends up mapped to both documents while the other terms map to only one each.