ReactiveSearch v8.24.0: Native kNN (Vector) search and filtering for Elasticsearch

ReactiveSearch API has introduced first-class support for vector search (kNN) since v8.24.0 (released in Feb 2025). This enables developers to seamlessly integrate vector similarity search alongside standard filters (term, range, or geo) on Elasticsearch and OpenSearch. In this post, we will focus on kNN searching with Elasticsearch.

ReactiveSearch API enables you to build bespoke search UIs by taking search intent and transforming it (structured queries, AI embeddings, filters) directly into optimized search engine DSL queries. This lets you focus on designing relevance, not wrangling low-level DSL syntax.

Why Vector Search?

Vector search (kNN) opens up semantic and similarity-based use cases:

Semantic Text Search: Retrieve documents based on their semantic similarity rather than keyword overlap.

Image Similarity: Rank images by feature vectors (embeddings), enabling “find similar” functionality.

Recommendation Engines: Find near-neighbor items for personalization or content-based recommendations.

Anomaly Detection: Identify outliers by distance metrics in high-dimensional embedding space.

Many production teams already rely on Elasticsearch for text-based queries and can now easily incorporate vector-based similarity with the same cluster.

A Quick Demo of ReactiveSearch kNN

ReactiveSearch simplifies vector search by letting you combine it with typical search filters. Here’s an example request to the _reactivesearch API endpoint showing a kNN query combined with a term filter (tags.keyword) and a traditional text-based search (one_liner):

This request is translated into a native Elasticsearch DSL query using the knn clause and a filter. The vector_data field holds high-dimensional embeddings, and the final ranking of results is determined by vector similarity.

{
    "_source": {
        "excludes": [],
        "includes": [
            "name",
            "one_liner",
            "tags"
        ]
    },
    "knn": {
        "field": "vector_data",
        "filter": {
            "bool": {
                "must": [
                    {
                        "bool": {
                            "must": [
                                {
                                    "bool": {
                                        "filter": {
                                            "term": {
                                                "tags.keyword": "Fashion"
                                            }
                                        }
                                    }
                                },
                                {
                                    "bool": {
                                        "must": {
                                            "bool": {
                                                "minimum_should_match": 1,
                                                "should": [
                                                    {
                                                        "multi_match": {
                                                            "fields": [
                                                                "one_liner"
                                                            ],
                                                            "operator": "or",
                                                            "query": "dresses",
                                                            "type": "cross_fields"
                                                        }
                                                    },
                                                    {
                                                        "multi_match": {
                                                            "fields": [
                                                                "one_liner"
                                                            ],
                                                            "fuzziness": 0,
                                                            "operator": "or",
                                                            "query": "dresses",
                                                            "type": "best_fields"
                                                        }
                                                    },
                                                    {
                                                        "multi_match": {
                                                            "fields": [
                                                                "one_liner"
                                                            ],
                                                            "operator": "or",
                                                            "query": "dresses",
                                                            "type": "phrase"
                                                        }
                                                    },
                                                    {
                                                        "multi_match": {
                                                            "fields": [
                                                                "one_liner"
                                                            ],
                                                            "operator": "or",
                                                            "query": "dresses",
                                                            "type": "phrase_prefix"
                                                        }
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "k": 12,
        "num_candidates": 12,
        "query_vector": [
            -0.002622403,
            -0.008986259,
            -0.012236752,
            ....
            //1536 values
        ]
    },
    "size": 10
}

ReactiveSearch automatically translates this high-level request into a detailed Elasticsearch kNN query with integrated filters. By simply specifying your intent, you get advanced vector semantics wrapped in a developer-friendly interface.

Note: ReactiveSearch is able to translate the search text input into an embedding vector based on a pre-configured model that can set through AI preferences.

ReactiveSearch AI preferences UI panel where user can set the default embedding model to use.

For embedding model choice, there is support for text-embedding-3-small, text-embedding-3-large and text-embedding-ada-002.

From Intent to Performance: Leveraging Elasticsearch at Scale

Since v8.16.0, Elasticsearch has been released as open source under the AGPL and has received multiple performance boosts in the 8.x series that make vector search production-ready at scale. Notable enhancements include improved concurrency for kNN graph traversal, advanced quantization (8‑bit/4‑bit) to reduce memory usage, and integrated filtering that enables sub‑50 ms kNN queries even when applying term or range constraints. Combined with robust indexing and search concurrency, these updates ensure that Elasticsearch can efficiently handle millions of vector documents.

Elasticsearch Performance & Tuning

Mapping & Index Creation:

• Enable index:true on dense_vector fields for approximate kNN.

• Consider quantized field types (int8_hnsw or int4_hnsw) to drastically reduce memory usage.

• For large embeddings (up to 4096 dims), ensure your cluster runs Elasticsearch 8.11+.

HNSW Parameters:

m: Higher means better recall at the cost of more memory.

ef_construction: Boost indexing quality vs. speed trade-off.

num_candidates: Raise this at query time for higher accuracy (with some latency increase).

Index Lifecycle & Segment Management:

• Avoid overly frequent refresh intervals to limit overhead when building HNSW graphs.

• Use force merges or well-sized shards to keep query latencies low.

Filtering & Hybrid Queries:

• Elasticsearch 8.x supports filters directly in knn queries.

• Combine text-based matches and vector queries in the same DSL call for powerful hybrid search.


Ready to add vector search to your application?

With ReactiveSearch API v8.24.0, you can seamlessly turn semantic intent—like text queries, AI-driven embeddings, and domain filters—into optimized Elasticsearch kNN queries. From sub-50ms latencies on millions of documents to powerful hybrid filtering and re-ranking, Elasticsearch 8.x has become a production-ready powerhouse for vector-based retrieval.

Ready to get started? Just add a vectorDataField in your ReactiveSearch queries and fine-tune Elasticsearch’s HNSW parameters. You’ll be serving lightning-fast semantic search results in no time. Create a new search cluster or use the upgrade option from your cluster dashboard to use v8.24.0

0
Subscribe to my newsletter

Read articles from Siddharth Kothari directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Siddharth Kothari
Siddharth Kothari

CEO @reactivesearch, search engine dx