Exercise 1: The Prefix Trick's Two Real Limits, and nameLower — Possible Solution ==================================================================== THE TWO REAL LIMITS ------------------------------ 1. Case-sensitivity: the prefix query compares strings exactly as stored, so searching "gr" will not match a document whose name field is stored as "Greek Yogurt" - the different casing simply doesn't match. 2. Prefix-only matching: the query only captures strings that begin with the search term. Searching "yogurt" will never find "Greek Yogurt", because "yogurt" doesn't appear at the very start of that name. THE FIELD ADDED TO FIX CASE-SENSITIVITY ------------------------------ This chapter adds nameLower, a second field storing an already-lowercased copy of name (name.toLowerCase()), written alongside name at add-item time. WHY THIS FIELD FIXES THE CASE PROBLEM ------------------------------ Firestore has no query-time equivalent of SQL's LOWER() function, so there's no way to lowercase a stored value at query time. Storing a pre-lowercased shadow field and querying against that instead means the comparison happens between two values that are already in the same case, regardless of how the original name was typed or cased when it was first entered. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly identifies both real limits (case-sensitivity and prefix-only matching) with concrete examples, and correctly explains that nameLower fixes the case problem specifically by storing a pre-lowercased shadow field rather than relying on a query-time lowering function Firestore doesn't have.