Chapter 45 · Amazon Opensearch Service
Subchapter 45.35
references/search-semantic-search-guide.mdMarkdown15 KBView on GitHub
This file is the entry point for the search capability. It covers vector / semantic / hybrid / sparse / dense / RAG retrieval on Amazon OpenSearch Service or Serverless. Supports Bedrock connectors (Titan, Cohere), self-hosted embedding models, FAISS HNSW vs Lucene, ELSER alternatives, and hybrid scoring.
SKILL.md routes here when the user is asking about search retrieval setup or design. Concrete triggers:
After loading this entry, you can discover every search-capability file from this list.
| User need | File |
|---|---|
| End-to-end semantic search setup | this file |
| Bedrock embedding connector | search-bedrock-connectors.md |
| Pick a dense embedding model | search-dense-vector-models.md |
| Pick a sparse embedding model (ELSER alt.) | search-sparse-vector-models.md |
| Configure index for vector / hybrid | search-index-config.md |
| Process / chunk documents for retrieval | search-document-processing-guide.md |
| Evaluate search quality | search-evaluation-guide.md |
| Query DSL recipes (BM25, multi_match, function_score) | search-recipes.md |
| Troubleshoot search issues | search-troubleshooting.md |
Cross-cutting refs you may also load: vector-knn.md (vector sizing math, k-NN engines), sizing.md, security.md.
engine/mode selection (system auto-picks); supports custom document IDs and 32x compression by default.engine: faiss; Lucene/IVF/PQ are NOT supported on Classic Serverless.r7g/r8g for memory-optimized; m7g/m8g for cluster managers). r6g/r6gd only with explicit justification.[BLOCKER — need input] OR present 2–3 tiered bands. Never present a single point estimate built on invented numbers.provisioning-reference.md.assessment-workflow.md.log-analytics-guide.md.search-dense-vector-models.md and search-sparse-vector-models.md.BM25 is the default ranking algorithm in OpenSearch. It calculates relevance based on term frequency (TF), inverse document frequency (IDF), and document length normalization.
| Aspect | Rating | Notes |
|---|---|---|
| Exact Match Precision | 5/5 | Excellent for exact keyword queries |
| Semantic Understanding | 2/5 | Cannot understand synonyms or paraphrases |
| Out-of-vocabulary Handling | 1/5 | Fails completely on unseen terms |
| Domain-specific Terms | 5/5 | Excellent for technical/domain vocabulary |
Strengths:
Weaknesses:
| Resource | Cost Level | Details |
|---|---|---|
| Storage | 1/5 (Low) | Only inverted index, typically 10-30% of raw text size |
| Memory | 1/5 (Low) | Field data cache only when needed |
| CPU (Indexing) | 1/5 (Low) | Simple tokenization and analysis |
| CPU (Query) | 1/5 (Low) | Efficient inverted index lookup |
Storage Estimation:
Index Size ≈ Raw Text Size × 0.1 to 0.3
Example: 1GB text → 100-300MB indexScaling Behavior:
BM25 supports several special query types that vector search cannot:
| Query Type | Description | Use Case |
|---|---|---|
prefix | Matches terms starting with specified prefix | Autocomplete, partial matching |
wildcard | Pattern matching with * and ? | Flexible string matching |
regexp | Regular expression matching | Complex pattern matching |
fuzzy | Tolerates spelling mistakes | Typo tolerance |
ngram | Matches character n-grams | Partial word matching |
phrase | Matches exact phrase in order | Exact phrase search |
span | Positional queries | Near queries, ordered matching |
term | Exact term matching (no analysis) | Exact value matching |
| Feature | Support Level | Notes |
|---|---|---|
| English | 5/5 | Excellent with standard analyzer |
| Other Languages | 4/5 | Requires language-specific analyzers |
| Cross-lingual | 0/5 | Not supported natively |
| CJK Languages | 3/5 | Requires specialized tokenizers (kuromoji, ik, etc.) |
Recommended:
Not Recommended:
Dense vector search uses neural network embeddings to represent text as dense floating-point vectors (typically 384-1536 dimensions). Similarity is computed using cosine similarity, dot product, or L2 distance.
| Aspect | Rating | Notes |
|---|---|---|
| Semantic Understanding | 5/5 | Captures meaning beyond keywords |
| Synonym Handling | 5/5 | Automatically handles synonyms |
| Cross-lingual | 5/5 | With multilingual models |
| Exact Match | 1/5 | Does not support exact keyword matches |
| Domain-specific | 3/5 | If your domain distribution differs greatly from general corpus, fine-tuning is required for good results |
Strengths:
Weaknesses:
Overview: Graph-based approximate nearest neighbor (ANN) algorithm. Default and most popular choice.
| Aspect | Details |
|---|---|
| Accuracy | 95-99%+ recall achievable with proper tuning |
| Build Time | Moderate to slow |
| Query Latency | Fast (1-50ms typically) |
| Memory Requirement | High - entire graph in memory (unless using quantization) |
| Scalability | Good, but memory-bound |
Memory Estimation (Raw):
Memory = num_vectors × (dimensions × 4 bytes + m × 8 bytes + overhead)
Example: 10M vectors × 768 dims, m=16
Memory ≈ 10M × (768 × 4 + 16 × 8) ≈ 32GBBest For:
Overview: Clustering-based approach that partitions vectors into clusters (buckets).
| Aspect | Details |
|---|---|
| Accuracy | 85-95% recall typical |
| Build Time | Slow (requires training) |
| Query Latency | Medium (5-100ms) |
| Memory Requirement | Lower than HNSW (especially with PQ) |
| Scalability | Better for large datasets |
Best For:
Overview: OpenSearch’s solution for billion-scale vector search with limited memory (requires OpenSearch 2.17+). Uses Binary Quantization (BQ) to keep a compressed index in memory while storing full-precision vectors on disk.
| Aspect | Details |
|---|---|
| Accuracy | Good recall (uses re-ranking from disk) |
| Build Time | Fast (BQ training is automatic) |
| Query Latency | Medium (10-100ms), depends on SSD speed |
| Memory Requirement | Very Low (uses 1-bit BQ compressed vectors in RAM) |
| Scalability | Excellent for billion-scale datasets |
Memory Estimation:
Memory = num_vectors × dimensions / 8 (bits to bytes) + HNSW graph overhead
Example: 1B vectors × 768 dims (using BQ)
Memory ≈ 1B × 96 bytes ≈ 96 GB (manageable on a cluster)
vs. ~3TB for float32 vectorsBest For:
Compression technique that breaks vectors into sub-vectors and encodes them.
| Aspect | Details |
|---|---|
| Accuracy | 80-90% recall (lossy) |
| Training | Requires a training step |
| Memory Reduction | 10-50x compression |
Extreme compression using 1-bit representations.
| Aspect | Details |
|---|---|
| Accuracy | Lower than PQ generally, but faster |
| Memory Reduction | 32x compression (float32 -> 1 bit) |
| Query Latency | Ultra-fast (Hamming distance) |
Total Latency = Embedding Inference Time + Vector Search Time (KNN)Critical Note: Often, inference time dominates the total latency.
| Feature | Support Level | Notes |
|---|---|---|
| English | 5/5 | Excellent with most models |
| Multilingual | 5/5 | With multilingual models (mE5, multilingual-e5, etc.) |
| Cross-lingual | 5/5 | Query in one language, retrieve in another |
| Low-resource Languages | 3/5 | Depends on model training data |
Recommended:
Not Recommended:
Sparse vector search uses learned sparse representations where most dimensions are zero. Unlike dense vectors with 384-1536 dimensions all populated, sparse vectors may have 30,000+ dimensions but only 100-500 non-zero values.
Uses neural networks to learn sparse representations with semantic meaning:
Advantages over BM25:
Why recommended: Zero query inference, low latency (10x+ faster), lower cost.
| Aspect | Rating | Notes |
|---|---|---|
| Semantic Understanding | 4/5 | Good, but generally slightly below dense |
| Exact Match | 4/5 | Better than dense vectors |
| Term Expansion | 5/5 | Learns relevant term expansion |
| Interpretability | 5/5 | Can see which terms matched |
Recommended:
Not Recommended:
Hybrid search combines multiple retrieval methods (BM25, dense vector, sparse vector) to leverage the strengths of each. OpenSearch supports hybrid search through the hybrid query type and score normalization.
OpenSearch provides several normalization techniques (Min-Max, L2, Harmonic Mean, etc.) to ensure scores are comparable before combination.
Hybrid Scope Rule: Use at most two retrieval methods per hybrid query.
Recommended Combinations:
Not Recommended:
Recommended:
Not Recommended:
This file