Exercise 1: Why "Yogurt" Finds "Greek Yogurt" — Possible Solution ==================================================================== WHY THIS MID-WORD MATCH WORKS ------------------------------ Chapter 8 presented two approaches: the Firestore where(">=")/where("<") prefix trick, which can only ever match strings starting with the exact search term, and a client-side approach that loads the user's full item history once and filters it in plain JavaScript using .includes() on the nameLower field. Searching "yogurt" against "Greek Yogurt" is a mid-word match - "yogurt" doesn't appear at the start of the name - which the Firestore prefix trick alone could never find, since it only captures strings beginning with the search term. WHICH APPROACH ACTUALLY POWERS THE REAL FEATURE ------------------------------ The chosen, actually-implemented search feature uses the client-side .includes() filtering approach, not the raw Firestore prefix query. Because .includes() checks whether the search term appears anywhere within the string, not just at the beginning, it correctly finds "Greek Yogurt" when searching "yogurt", exactly the case the prefix-only trick was shown earlier in Chapter 8 to be incapable of handling. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly identifies that a mid-word match is exactly what the Firestore prefix trick cannot do, and correctly explains that the actual implemented feature uses client-side .includes() filtering instead, which is why the mid-word match in Maya's session genuinely works.