Search Infrastructure
Why a plain database query stops being enough the moment a search box needs to feel fast and forgiving.
5.12.1Definition
Search infrastructure is a dedicated system — Elasticsearch, Algolia, Meilisearch, or a database's built-in full-text search — optimized for fast, ranked, typo-tolerant lookups across large text datasets, as distinct from the exact-match filtering a standard SQL WHERE clause performs well.
5.12.2Why It Exists
Relational databases are built for exact and range matching, not for ranking relevance, tolerating typos, or searching across many fields simultaneously with weighted importance — the actual expectations users have of a search box (3.21). Dedicated search infrastructure exists to serve that specific access pattern well, typically as a separately-maintained index kept in sync with the primary database rather than the source of truth itself.
5.12.3When Plain Database Search Is Enough
| Signal | Database search is fine | Dedicated search engine needed |
|---|---|---|
| Dataset size | Thousands of rows | Hundreds of thousands+ |
| Query needs | Exact/prefix match on one or two fields | Typo tolerance, relevance ranking, faceting |
| Latency expectation | A second or two is acceptable | Sub-100ms, instant-as-you-type |
5.12.4Common Mistakes
- Adopting Elasticsearch for a dataset a database index would handle fine, adding an entire second system to keep in sync for no measurable user benefit.
- Letting the search index drift out of sync with the primary database, with no reliable re-indexing process when underlying data changes.
- Building "search" as a simple
LIKE '%query%'query on a large table, which cannot use standard indexes efficiently and degrades badly as data grows.
5.12.5Best Practices
- Start with the database's native full-text search capability; migrate to dedicated search infrastructure only once a specific, measured limitation appears.
- Treat the search index as a derived, rebuildable copy — never the source of truth for the underlying data.
- Build an explicit, monitored re-indexing pipeline rather than assuming the index will stay in sync on its own.