Architectural Breakdown & AnalysisFAANG Aligned
SQL LIKE '%keyword%' queries cause full table scans that fail at scale. Elasticsearch uses an Inverted Index for instant fuzzy searches and faceted filtering.
1. Inverted Index Mechanics
A dictionary mapping every unique word to the specific document IDs containing it. Searching "Wireless Noise Canceling Headphones" intersects candidate lists in milliseconds.
2. Sharding & Replica Distribution
- Primary Shards: Document collections are partitioned across primary shards (
hash(_id) % primary_shards). - Replica Shards: Read-only copies of primary shards. Replicas scale concurrent search queries horizontally and guarantee failover.
WARNING — Primary Shard Immutability
Primary shard count cannot be changed after index creation without re-indexing. Plan primary shard sizing based on 3-year data growth projections.
Key Architectural Comparison
| Catalog Search Pattern | Query Engine | Search Latency | Fuzzy / Typo Support | Multi-Facet Filters |
|---|---|---|---|---|
| SQL `LIKE '%term%'` | Relational DB | $> 1,000\text{ms}$ (Full scan). | None. | Slow (requires multi-index scans). |
| Elasticsearch (Lucene) | Inverted Index | $< 30\text{ms}$. | Levenshtein edit distance built-in. | Instantaneous facet aggregations. |
| Vector Search (ANN) | HNSW Graph Index | $< 50\text{ms}$. | Semantic conceptual matching. | Requires hybrid vector + scalar filter. |