Choosing a k-NN engine in OpenSearch: Faiss, Lucene or JVector

Choosing a k-NN engine in OpenSearch depends on dataset size, indexing throughput, memory budget, filtering needs and whether vectors must stay on disk. This page explains each engine, the HNSW and IVF method choice, and what to confirm before you build the index.

On this page

Choosing a k-NN engine in OpenSearch for your vector workload

If you are building a vector index on a self-hosted OpenSearch cluster, pick the k-NN engine and method before you map the knn_vector field. The engine and method are fixed per field in the mapping, so changing them later generally means creating a new index and reindexing your vectors. OpenSearch supports three engines: Lucene, Faiss and JVector. The NMSLIB engine is deprecated, so new work should not start on it. HNSW is implemented by all three engines, and Faiss also implements IVF, which changes the trade-offs between search speed, memory, training time and the need for training data.

Teams usually face this decision at one of three points. A team with a modest corpus that needs filtered search alongside vectors often starts with Lucene. A team indexing large volumes or needing fast bulk indexing tends to evaluate Faiss. A team whose vectors will not fit in memory on the nodes it can afford looks at JVector's disk-based search. Each of these starting points depends on your data size, filter selectivity, recall target and hardware, so write those numbers down before you read the engine documentation. Confirm current engine capabilities, supported parameters and filter behavior against the OpenSearch methods and engines documentation, since engine support changes between releases.

Test your choice with a representative sample of your own vectors and queries before committing the mapping. Measure recall against exact search, latency at the concurrency you expect, indexing time and the memory each candidate needs. Record the engine, method, space type and parameters together with the results, because those settings are what you will need if you later move to a different engine or need to rebuild the index. Ask your DeployOpen or internal team to confirm these results against your production hardware, not only a test node.

How Lucene, Faiss and JVector differ in practice

The OpenSearch documentation positions the Lucene engine for smaller datasets, up to a few million vectors. In that range the docs describe better latency and recall alongside the smallest index size, which makes Lucene a natural first candidate for a modest vector collection that sits next to keyword fields. Lucene is also the engine to evaluate first when k-NN queries must be combined with filters on metadata, since filtering behavior is a common deciding factor for application teams.

  • Dataset size: the docs frame Lucene around collections of up to a few million vectors, so larger collections need a separate test before the choice is made.
  • Latency and recall: the docs describe better latency and recall than the alternatives at this scale, which should be measured on your own queries.
  • Index size: the docs describe the smallest index size among the three engines for this range.
  • Filtering: Lucene is the engine the docs point to for filtered k-NN workloads, so test filter selectivity against your real metadata.
  • Operational footprint: Lucene runs inside the OpenSearch process, so capacity planning follows the existing node sizing.

Before committing, confirm the current size guidance, supported method parameters and filtering behavior for your OpenSearch version in the vector search documentation, and benchmark with a representative sample.

HNSW versus IVF: which method fits your index

The method decision comes down to whether you need one graph-based method that every OpenSearch k-NN engine supports, or IVF, which only the Faiss engine offers. HNSW is implemented by Lucene, Faiss and JVector alike, so choosing HNSW keeps the engine decision open and makes it easier to move later. IVF, the inverted file approach, is available only through Faiss, so selecting it ties the index to that engine and to its training workflow. Start from the engine you have already chosen, then check which methods that engine offers in the OpenSearch methods and engines documentation.

The FAISS README frames every index type as a trade-off across six properties: search time, search quality, memory per vector, training time, adding time and the need for training data. HNSW generally needs no training pass and accepts vectors as they arrive, which suits indexes that grow continuously, but it keeps a graph structure in memory that costs more per vector. IVF partitions vectors into clusters and can be lighter on memory and faster to build at large scale, but its search quality depends on how many clusters are probed at query time. Test both methods on a sample of your own vectors and queries, and record latency, recall and memory for each before settling on one.

IVF requires training data. The index must be trained on a representative sample of vectors before documents are added, so the cluster centroids reflect your data. If your content changes substantially, you may need to retrain and rebuild the index, which affects how you plan reindexing windows and pipelines. Before choosing IVF, confirm the training call, the sample size requirements, the sequence for loading data after training, and how reindexing works for your OpenSearch version in the current OpenSearch docs. If that workflow does not fit your release cadence or data change rate, HNSW on Faiss is the simpler path.

Decision factors that should drive the engine choice

The engine choice follows from a few workload facts: how many vectors you hold, how fast they arrive, how much memory each node can spare, and whether queries filter on metadata. Answer these before comparing engines, because each factor points toward a different combination of engine and method.

Dataset size

Ask how many vectors the index will hold now and after two years of growth. The OpenSearch docs suggest Lucene for smaller datasets of up to a few million vectors, where it shows better latency and recall and the smallest index size. Above that range, benchmark Faiss and Lucene against your own vectors and query mix rather than relying on a single threshold. Confirm the expected vector count and dimension with the data owner before testing.

Lucene sweet spot
Few million
Performance tuning docs

Indexing throughput needs

Ask whether vectors arrive in bulk loads, as a continuous stream, or both. The docs suggest Faiss when indexing throughput is the priority. If your pipeline re-embeds large corpora on a schedule, measure build time on a representative sample for each engine and method before choosing. Record the ingest rate you need, because it shapes shard count and refresh settings as well as the engine.

Memory per node and compression

Ask how much heap and off-heap memory each data node can give to vector graphs, and whether you will compress vectors to fit. Faiss offers compression methods that keep a reduced representation in memory, trading some precision for capacity. Lucene provides its own quantization options. Check which compression each engine supports for your chosen method, since the supported combinations differ and affect recall.

Filtering requirements

Ask whether most queries combine vector similarity with metadata filters such as tenant, region or date. Lucene is the direction to test first when filtering is central, because the docs position it for smaller datasets with the smallest index size and better latency and recall. Write a representative filtered query set, including selective filters that match few documents, and measure recall against an exact search baseline.

Disk-based search needs

Ask whether the cluster must hold far more vectors than RAM allows and whether some added query latency is acceptable. JVector is the engine direction for disk-based search, so include it in your evaluation if memory cannot hold the graphs. Confirm JVector's supported methods, compression options and disk and latency behavior in the current OpenSearch release notes, since these vary by version and your hardware.

NMSLIB deprecation

Ask whether any existing index or application uses the NMSLIB engine. OpenSearch has deprecated NMSLIB, so new indexes should not start on it. Inventory current knn_vector mappings, plan a re-index onto a supported engine, and test recall after the move. Confirm the deprecation timeline and removal plans with the OpenSearch release notes for your target version before scheduling the change.

Methods and engines docs

Engine and method options and when each fits

This table compares the k-NN engine and method pairings available in OpenSearch against the workloads they suit. Read each row against your dataset size, memory budget, filtering needs and disk constraints, then use the confirm column to check details against current engine documentation before you commit to an index mapping.

Engine and methodBest-fit workloadDocumented strengthsDocumented trade-offs and what to confirm
Lucene with HNSWSmaller datasets of up to a few million vectors, where latency and recall matter more than indexing throughputThe docs show better latency and recall at this scale and the smallest index sizeConfirm how your dataset size and filter selectivity behave in a test index before committing; the docs position it for smaller datasets
Faiss with HNSWLarger vector sets where indexing throughput and compression options matterThe docs suggest Faiss to optimize indexing throughput; Faiss is also the default engine for knn_vector fieldsConfirm memory per vector and build time at your volume, and whether your compression level affects recall for your queries
Faiss with IVFWorkloads that need an alternative to graph-based search, with the training step built into the index planIVF is implemented by Faiss only, so it is an option when you want a method other than HNSW from the Faiss engineIndex types trade search time, search quality, memory, training time and adding time; confirm training data needs and the retraining process
JVectorDisk-based vector search where index data is kept on disk rather than fully in memoryDocumented as the engine for disk-based search in OpenSearchConfirm the supported method, the latency you can accept from disk access and the engine version your cluster runs
NMSLIB (deprecated)Not recommended for new indexesStill referenced in older indexes and mappingsDeprecated by the OpenSearch project. Do not create new indexes on it; plan a reindex to Lucene, Faiss or JVector for existing indexes

Walk the engine decision path from dataset size to method

The path starts with dataset size, since the docs point to Lucene for smaller datasets of up to a few million vectors. The next hand-off asks whether the team needs high indexing throughput, which points to Faiss, or filtering, which keeps Lucene in view. Disk-based search leads to JVector. Each branch ends in an engine and method choice, and the last check confirms that the OpenSearch version in use supports that engine and method before the mapping is written.

Decision path from dataset size and workload to an engine and method.

Steps to set the engine on a knn_vector field

This sequence takes the engine and method decision from version check to a validated mapping, so the choice is based on your OpenSearch version, your data size and measured recall and latency rather than on defaults. The output is a signed-off mapping ready for production data.

  1. Confirm version and engine support

    Start by checking which OpenSearch version your cluster runs and which engines and methods that version supports for knn_vector fields. Compare your planned engine and method against the methods and engines documentation for that exact version, and confirm that NMSLIB is deprecated for any new index you create. The platform or search engineer who owns the cluster does this step. It is done when you have written down the version, the engine and the method you plan to use, with the documentation page you checked.

  2. Size the dataset and memory budget

    Count the vectors you expect now and over the retention period, along with the vector dimension and the number of replicas. Estimate memory per node for each candidate engine, and note whether your data has to be filtered by metadata at query time, since that affects engine choice. The search architect and the capacity owner complete this together. It is done when you have a written table of vector count, dimension, replicas and projected memory for each candidate, and you can state which candidate fits your nodes.

  3. Define the knn_vector mapping

    Write the index mapping with the knn_vector field, the dimension that matches your embedding model, and the engine, method name, space type and parameters you selected. Keep the mapping in version control so every change is reviewed. The search engineer writes the mapping and a second engineer reviews it. It is done when the mapping file passes review and the dimension is confirmed against the embedding model's output size in its own documentation.

  4. Create a test index

    Create a separate test index from the reviewed mapping on a non-production cluster or a non-production index alias. Confirm the index is created without errors and that the field reports the expected engine and method settings when you read the mapping back. The engineer running the test owns this step. It is done when the mapping read-back matches the reviewed file and the index accepts sample documents.

  5. Load a representative sample

    Load a sample that reflects production: similar vector dimensions, similar metadata fields, and a realistic mix of filtered and unfiltered queries. Use the same embedding model that production uses so the vectors match. The data owner and the search engineer confirm the sample before loading. It is done when the test index holds the agreed sample count and document counts match the source.

  6. Check recall and latency

    Run a set of reference queries with known nearest neighbors, either from an exact search or from a labeled judgment set, and measure recall against that baseline. Measure query latency at the concurrency you expect in production, and record indexing throughput and memory use during the load. The search engineer runs the tests and the team reviews the results together. It is done when recall and latency for each candidate are recorded side by side and the results meet the targets your team set before testing.

  7. Confirm the decision before production

    Compare the recorded results with your memory budget and your requirements for filtering and indexing speed, then choose one engine and method. Record the decision, the reasons and the tested mapping in your change record, and get sign-off from the owner of the search service. Load production data only after this sign-off. It is done when the signed decision record names the engine, method, version and mapping, and the production index is created from that same reviewed file.

Security and operational considerations for vector indexes

Vector indexes hold embeddings that often encode the content of the source documents, so they inherit the sensitivity of that data. The cards below cover the controls to set before the engine choice is locked in, and the operational checks that follow the choice.

Role-based access to k-NN indexes

Vector indexes are read and written through the same Security plugin roles as any other index, so a role must grant only the index patterns and actions a team needs. Confirm which index permissions cover k-NN searches and bulk loads in your OpenSearch version, and test each role with a real query before rollout. Keep embedding writers separate from search readers so that a pipeline account cannot read other teams' vectors.

Security docs

Document-level security on shared vectors

When one index holds vectors for several tenants or classification levels, document-level security filters which vectors a role can match, and field-level security or field masking limits which stored fields come back. Check that the filter is applied to approximate k-NN results, not only to exact lookups, because a filter that appears to work in a basic query can still leak through a poorly tested path. Plan separate indexes instead when the isolation requirement is strict.

TLS for client and node traffic

Embedding services, ingest jobs and application clients send full-length vectors and query text across the network, so TLS should cover client traffic and inter-node traffic alike. Confirm certificate sources, rotation procedures and which clients must trust the internal certificate authority before the first load. Vectors sent in plain text can reveal document content even without the original text.

Audit logging for vector access

Audit logs record who accessed which indexes, which lets you answer questions about who queried sensitive embeddings. Decide which events to capture, where logs are stored and how long they are kept before the first production index is created. Ask your team to confirm that audit records of k-NN queries and bulk writes are captured at the level your compliance reviewers expect.

Memory headroom on data nodes

Graph-based engines load index structures into native memory outside the JVM heap, so a node that looks healthy in heap metrics can still run short during merges or when a new index is added. Size the nodes for the chosen engine and method, and leave headroom for indexing peaks and for a second copy of an index during reindexing. Ask for a measured estimate on a sample of your own vectors before you commit to node counts.

Reindexing and rollback after engine changes

The engine and method are set in the index mapping, and changing them generally means building a new index and reindexing the source documents. Keep the source data and the embedding pipeline reproducible so a rollback is a repointed alias rather than a rebuild from scratch. Run old and new indexes side by side for a test window, and record the mapping and version of each index so that a failed cutover can be reversed quickly.

Questions teams ask before choosing a k-NN engine

Is Faiss the default k-NN engine in OpenSearch?

Yes. OpenSearch uses Faiss as one of its vector search engines and as the default engine for knn_vector fields, according to the OpenSearch methods and engines documentation. Being the default does not mean it fits your data. The docs suggest Faiss for indexing throughput and compression, while Lucene suits smaller datasets of up to a few million vectors, especially when filtering matters. Check your engine and method explicitly in the index mapping rather than relying on defaults, and confirm the settings against the methods and engines documentation for your OpenSearch version.

What drives the cost and effort of a k-NN engine benchmark?

The main drivers are dataset size and dimensionality, how representative your sample queries are, how many filter combinations you must test, and how many engine and method variants you compare (for example HNSW with Faiss, HNSW with Lucene, and JVector on disk). Effort also grows with the number of recall and latency targets you set and with the hardware you test on, since memory and CPU limits change the answer. If you use a partner, the quote should itemize data preparation, test cluster setup, query and filter test design, the measurement report and any retest. Ask who owns the test cluster and who pays for its compute.

Can we change the k-NN engine later, and what does that cost?

Changing the engine or method on a knn_vector field generally means creating a new index with the new mapping and reindexing the vectors into it, then switching reads over. The cost scales with vector count, embedding dimensions, the time to rebuild graphs, and how much downtime or dual running your applications tolerate. Plan for a cutover window and keep the source index until the new one passes your recall and latency checks. Confirm the exact mapping change and reindex behavior for your OpenSearch version before committing, because the cost of a wrong first choice is mostly paid in reindexing and retesting.

Can our own engineers run the engine evaluation without a partner?

Yes, if your team has OpenSearch cluster experience, access to representative embeddings, and time to run controlled tests. The work is mostly disciplined measurement: fixed query sets, recall measured against exact search, latency at realistic concurrency, and repeated runs. Teams that stall usually lack a clear pass or fail threshold, or they test on a cluster that does not match production memory and node counts. A partner is useful when you need an independent report for a security or architecture review, or when you want the benchmark to feed a documented decision. Either way, write the success criteria before running anything.

How long does a k-NN engine benchmark usually take?

The duration depends on your dataset, the number of engine and method variants, the test hardware, and how many people must review the results. Loading large vector sets and rebuilding graphs for each variant often takes most of the time, and each round of tuning adds more. Ask any partner or internal team for a schedule that separates data preparation, cluster build, test execution, analysis and the final report, and for the number of iteration rounds they assume. A plan without those steps is hard to verify.

Does Faiss carry a license cost?

No. FAISS is released under the MIT license and is maintained in the facebookresearch GitHub organization, according to its README. OpenSearch itself is released under the Apache License, Version 2.0, and the OpenSearch FAQ does not describe a paid edition. Your costs for Faiss come from compute, memory, storage and the people who operate and test the cluster, not from a license fee. Review your own legal team's requirements for open-source license compliance, including any notices you must keep, and confirm them against the project's license file.

What should we ask a partner for in a quote for this work?

Ask for a written scope that names the datasets, the engines and methods to compare, the recall and latency targets, the filter patterns to test, and the hardware or cluster sizing used for tests. Request the deliverables in writing: test scripts or configuration, raw results, a findings report with a recommended engine and method, and a list of open risks. Clarify whether a retest is included, who provides the test infrastructure and its cost, and what support follows the handover. A fixed-scope quote lets you compare options on the same basis.

Should we choose HNSW or IVF for our index?

HNSW is implemented by all three engines, while IVF is available in Faiss. HNSW is the common starting point for approximate search with strong recall at low latency, but it holds graph structures in memory unless you use disk-based options. IVF partitions vectors into clusters and needs training data, which adds a build step and tuning effort. Choose IVF only when a Faiss-specific trade-off, such as memory or build behavior at very large scale, clearly favors it in your benchmark. Confirm the parameters and training requirements for your OpenSearch version in the vector search documentation before you test.

What a scoped engine evaluation delivers

A fixed-scope engine evaluation for this decision usually starts with a workload review of your vector fields: vector count and dimension, expected growth, whether queries carry filters, the required recall and latency targets, and where the cluster runs. The output is a written record of those inputs, plus the current or planned cluster sizing, so that the engine choice between Faiss, Lucene and JVector is tied to your numbers rather than to general guidance. Ask whether the review also covers existing indexes if you are migrating from another engine or from NMSLIB, which is deprecated.

The central deliverable is a benchmark plan on your own data. It defines the sample set, the query set with filter patterns, the recall measurement method, the candidate engines and HNSW or IVF methods to compare, and the parameters held constant. Run it on hardware that matches the target nodes. The result is a recommendation of engine and method with its rationale, including the memory and indexing trade-offs observed and any caveats. Confirm with the provider how many configurations are benchmarked and whether results are delivered as raw data as well as a summary.

The handover includes the index mapping, the knn_vector field settings such as method, engine and space_type, the query templates, and the operating notes for later changes. Scope, deliverables and timelines are agreed in writing before work starts, and DeployOpen does not publish a price list, so the quote follows from that written scope. Ask for each deliverable to be listed separately, with acceptance criteria and any retest included in the fixed price.

How DeployOpen scopes and supports OpenSearch vector work

DeployOpen starts by writing down which engine, method and index settings fit your dataset, filters, memory budget and hosting constraints for Choosing a k-NN engine in OpenSearch: Faiss, Lucene or JVector. We build and test that choice inside your own infrastructure, then hand over the configuration, benchmarks and runbooks your team needs to operate it.

How we scope

  • Engagements are fixed-scope, with the engine, method and deliverables agreed in writing before work starts.
  • Scoping records vector count, dimensions, filter patterns, memory limits and target latency and recall for your dataset.
  • The written scope names which OpenSearch version, hosting model and infrastructure the engine choice must run on.

How we build

  • We create test indexes for Lucene, Faiss and JVector candidates and measure recall, latency and index size on your data.
  • Build work covers knn_vector mappings, method settings and any quantization or on_disk configuration chosen in scoping.
  • Testing includes filtered queries, indexing load and node failure scenarios, with results documented against the agreed criteria.

How we hand over

  • You receive the final mapping, index settings, benchmark results and the reasoning behind each engine and method decision.
  • Documentation covers how to add a new engine or method later, including the consequences for reindexing existing data.
  • A handover session walks your platform and search teams through operating the index and reading its health and performance signals.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, including retesting after OpenSearch minor releases.
  • Retainers can cover re-benchmarking when your dataset grows past the sizes used in the original decision.
  • Confirm with us in the quote which versions, environments and response expectations the retainer includes in writing.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.