How do you implement full-text search with Firestore?
Answer
Firestore does not support native full-text search — its querying is limited to exact matches, range queries, and array operations. Solutions: (1) Algolia — most popular choice. Sync Firestore data to Algolia via Cloud Functions on write triggers. Algolia provides typo-tolerant, faceted full-text search with client-side SDKs; (2) Typesense — open-source Algolia alternative; self-hosted or cloud; (3) Elasticsearch/OpenSearch — most powerful but most complex; stream Firestore data via Cloud Functions to an Elasticsearch cluster; (4) Firebase Extensions — the Search with Algolia and Search with Typesense extensions automate Firestore-to-search-provider sync without custom Cloud Functions; (5) Client-side prefix matching — for simple prefix search (not full-text), use: query(collection(db, "users"), orderBy("name"), startAt(searchTerm), endAt(searchTerm + "")). The character is the highest Unicode character, making the range match all strings starting with searchTerm; (6) Vector search — Firestore now supports vector embeddings for semantic/AI-powered search.