AWS Builder Center
Fast App Search with Amazon OpenSearch: Stop Killing Your Database with SQL LIKE

Fast App Search with Amazon OpenSearch: Stop Killing Your Database with SQL LIKE

Discover why SQL LIKE queries crash under search traffic and how a dedicated Amazon OpenSearch Domain delivers instant autocomplete, typo tolerance, and millisecond query speeds.

If your application uses queries like this to power its search bar:
SELECT * FROM products WHERE name ILIKE '%chair%';
You are sitting on a performance time bomb.
As your database grows, every search forces a full-table scan. CPU spikes to 100%, queries freeze, and your primary database chokes.

The Shift: Sequential Scanning vs. Inverted Index

Relational DB vs OpenSearch Search Engine

  • Relational DB (Slow): Checks every single row sequentially one by one.
  • OpenSearch Domain (Fast): Uses an Inverted Index—a pre-built map of words pointing directly to documents. Lookups take single-digit milliseconds, regardless of catalog size.

Why an OpenSearch Domain Wins for Search

  • ⚡ Instant Autocomplete: Returns results as users type their first 2 letters.
  • 🎯 Typo Tolerance: A search for  "ergonmic"  automatically finds  "ergonomic" .
  • 📊 Relevance Ranking (BM25): The best matches appear at the top, not just random alphabetical rows.
  • 🚀 Independent Scaling: Add replica shards to double your search capacity during traffic spikes without touching your primary database.

30-Second Implementation

1. Create a Search Index with Fuzzy Matching

PUT /products
{
"mappings": {
"properties": {
"name": { "type": "text" },
"category": { "type": "keyword" },
"price": { "type": "float" }
}
}
}

2. Run a Multi-Field Query with Typo Tolerance

GET /products/_search
{
"query": {
"multi_match": {
"query": "chair",
"fields": ["name^2", "category"],
"fuzziness": "AUTO"
}
}
}
(The  name^2  boost guarantees product titles rank higher than category names).

3 Golden Rules for Search Domains

  1. Prioritize Memory over Disk: Use memory-optimized nodes ( r6g  or  m6g ) so frequently searched terms live in RAM.
  1. Keep Shards Small (10–30 GB): Smaller shards yield significantly lower search latencies than massive log shards.
  1. Always Use 3 Dedicated Master Nodes: Never let data nodes manage cluster state in production.

Keep your SQL database for transactions (orders, payments, users). Offload search to a dedicated Amazon OpenSearch Domain. Your users get instant results, and your primary database stays fast.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article