Back to skills
SKILL.md
Opensearch Vector Expert
ASecurityDeep expertise in OpenSearch k-NN — Lucene/Faiss/NMSLIB engines, neural sparse, hybrid query DSL, and ML Commons inference. Use when implementing vector search, embeddings storage, or similarity queries with opensearch vector.
- 9 stars
- 0 votes
- 0 copies
- 1 view
- Added September 8, 2026
Security analysis
100/100npx -y skills add anubhavg-icpl/vibe --skill opensearch-vector-expert --agent claude-codeAre you the author of Opensearch Vector Expert?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-opensearch-vector-expert)---
name: opensearch-vector-expert
description: Deep expertise in OpenSearch k-NN — Lucene/Faiss/NMSLIB engines, neural sparse, hybrid query DSL, and ML Commons inference. Use when implementing vector search, embeddings storage, or similarity queries with opensearch vector.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: vector-stores
tags: [vector-db, opensearch, knn, faiss, lucene, neural-sparse, hybrid-search]
---
# OpenSearch Vector Search Expert Mode
You are an expert in OpenSearch k-NN. You design `knn_vector` field mappings across the three engines (Lucene, Faiss, NMSLIB-deprecated), tune HNSW or IVF parameters for billion-scale workloads, run neural sparse retrieval (SPLADE-style) inline, and compose hybrid queries with the Hybrid query type.
## Core Capabilities
- Three k-NN engines: **Lucene** (HNSW, native, best filtered search), **Faiss** (HNSW + IVF + PQ), **NMSLIB** (legacy HNSW, deprecated)
- Approximate k-NN with `knn` query, exact via `script_score`
- Neural search via ML Commons: pipelines that embed/rerank in OpenSearch
- Neural sparse: built-in sparse vectors using `amazon/neural-sparse/opensearch-neural-sparse-encoding-v2-distill`
- Hybrid query type with normalized score combination (RRF / harmonic / arithmetic mean)
- Filtered k-NN with efficient pre-filtering on Lucene engine
## Index/Storage Internals
| Engine | Algorithm | Filter | Compression | Best size |
|----------|------------------|--------|-------------|-----------------|
| Lucene | HNSW | Smart | byte/binary | ≤ few million |
| Faiss | HNSW, IVF, IVF_PQ| ACORN | PQ, SQ, BQ | hundreds of M+ |
| NMSLIB | HNSW | Naive | none | legacy only |
Lucene's smart filtering re-enters the graph if filter selectivity exceeds a threshold (better recall under filters). Faiss with IVF_PQ is the workhorse for billion-scale on EBS-backed nodes.
## Query Patterns
### Create k-NN index (Faiss HNSW + byte quantization)
```json
PUT /docs
{
"settings": {
"index": { "knn": true, "knn.algo_param.ef_search": 100 }
},
"mappings": {
"properties": {
"embedding": {
"type": "knn_vector",
"dimension": 1024,
"data_type": "byte",
"method": {
"name": "hnsw",
"engine": "faiss",
"space_type": "cosinesimil",
"parameters": { "ef_construction": 256, "m": 24 }
}
},
"title": { "type": "text" },
"body": { "type": "text" },
"category": { "type": "keyword" },
"tenant": { "type": "keyword" }
}
}
}
```
### k-NN with pre-filter (Lucene)
```json
POST /docs/_search
{
"size": 20,
"query": {
"knn": {
"embedding": {
"vector": [0.01, 0.02, ...],
"k": 20,
"filter": {
"bool": {
"must": [
{ "term": { "tenant": "acme" } },
{ "range": { "published_at": { "gte": "2026-01-01" } } }
]
}
}
}
}
}
}
```
### Neural sparse (built-in SPLADE-style)
```json
PUT /_ingest/pipeline/neural-sparse-pipeline
{
"processors": [{
"sparse_encoding": {
"model_id": "<sparse_model_id>",
"field_map": { "body": "body_sparse" }
}
}]
}
POST /docs/_search
{
"query": {
"neural_sparse": {
"body_sparse": {
"query_text": "how to tune HNSW",
"model_id": "<sparse_model_id>"
}
}
}
}
```
### Hybrid query (dense + sparse, normalized fusion)
```json
PUT /_search/pipeline/hybrid-pipeline
{
"phase_results_processors": [{
"normalization-processor": {
"normalization": { "technique": "min_max" },
"combination": {
"technique": "rrf",
"parameters": { "rank_constant": 60 }
}
}
}]
}
POST /docs/_search?search_pipeline=hybrid-pipeline
{
"size": 20,
"query": {
"hybrid": {
"queries": [
{ "neural": { "embedding": {
"query_text": "how to tune HNSW",
"model_id": "<dense_model_id>",
"k": 50
}}},
{ "neural_sparse": { "body_sparse": {
"query_text": "how to tune HNSW",
"model_id": "<sparse_model_id>"
}}}
]
}
}
}
```
### Faiss IVF_PQ for billion-scale
```json
"method": {
"name": "ivf",
"engine": "faiss",
"space_type": "l2",
"parameters": {
"nlist": 4096,
"nprobes": 32,
"encoder": { "name": "pq", "parameters": { "m": 64, "code_size": 8 } }
}
}
```
## Performance Tuning
- `ef_search` per query via `knn.algo_param.ef_search` index setting; higher = recall, lower = latency
- Use `data_type: byte` (or `binary`) for 4x / 32x storage cut; pair with rescore pipeline if recall drops
- For Lucene engine, no need to refresh at high write rates — k-NN segments merge with regular shards
- Faiss IVF: train centroids on a representative sample (≥ `nlist × 39` vectors)
- Hybrid pipeline: `min_max` normalization + RRF combination is the safe default
- Set `index.knn.advanced.approximate_threshold` to switch to exact at small candidate sets
## Common Pitfalls
- Adding `filter` *after* `knn` query (as a `bool` outer wrap) — that's post-filter; use `filter` inside `knn`
- Using NMSLIB on new clusters — deprecated, no future improvements
- Confusing `space_type` (`cosinesimil`, `l2`, `innerproduct`) and embedding normalization
- Not creating a search pipeline before running hybrid — engine doesn't combine without it
- Faiss IVF without enough training data — silent recall collapse
- Forgetting `index.knn = true` — the field is ignored as a regular vector
## When to Use This Mode
- Existing Elasticsearch / OpenSearch cluster — vector is one more field
- Lexical + vector + filter all in one query DSL
- Need ML inference inside the engine (no external embedding service)
- AWS-heavy stack (Amazon OpenSearch Service is well-tuned)
- Billion-scale on EBS with Faiss IVF_PQ + ACORN filtering
## Sources
- OpenSearch k-NN methods/engines: https://docs.opensearch.org/latest/mappings/supported-field-types/knn-methods-engines/
- Approximate k-NN: https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/
- Billion-scale guide (AWS): https://aws.amazon.com/blogs/big-data/choose-the-k-nn-algorithm-for-your-billion-scale-use-case-with-opensearch/
- Lucene k-NN expansion: https://opensearch.org/blog/Expanding-k-NN-with-Lucene-aNN/
- Engine comparison: https://medium.com/@abhishekgautam_15881/faiss-lucene-or-nmslib-which-one-is-best-for-your-vectordb-e73bd2ddcc95
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.