Build an "index" over large amounts of text so you can find the most relevant content by keyword in seconds.
Why use it
LIKE '%phone%' starts with a wildcard, so the database cannot use a normal index and must scan row by row. Fine for a few thousand rows; slow at millions. It also cannot do:
Tokenization: split “apple phone case” into “apple / phone / case” and match each part.
Relevance ranking: put the best matches first.
Fault tolerance: still find results after a typo.
Highlighting and faceted counts (filter panels).
When you do not need it
With little data (tens of thousands of rows or fewer) and only exact or prefix matches, the database’s own indexes or full-text search (such as PostgreSQL full-text search) is enough — do not rush to run another system.
How to do it
A search engine is not the system of record; it is a replica:
Business data still lives in the relational database — see Database choice.
When data changes, sync it to the search engine (via a message queue or outbox).
Queries hit the search engine; when you need details, load them from the database by ID.
🔀 The search engine is a replica of the database
User
App
Database
Search engine
1Write business data (source of truth)
2Sync a copy into the index (with lag)
3Search "phone case"
4Query by keyword
5Return matching IDs, ranked by relevance
6Load details by ID when needed
Choosing a solution
Option
Traits
Best for
Elasticsearch
Richest features; strong aggregations
Large data, log search, complex queries
OpenSearch
Forked from Elasticsearch; friendlier open-source license