🆕 Find the k-nearest neighbors (k-NN) for your vector data https://opensearch.org/docs/latest/search-plugins/knn/index/
  • Java 91.9%
  • C++ 7.3%
  • CMake 0.5%
  • C 0.2%
Find a file
Ian Dees 7de66791d2
Fix native thread leak in Lucene HNSW merge executor (#3102) (#3533)
getMergeThreadCountAndExecutorService() created a new FixedThreadPool on
every invocation but never shut it down. Since this is called per field
per segment during flush/merge, thread pools accumulated unboundedly
(77k+ leaked threads observed, causing OOM kills).

Replace Executors.newFixedThreadPool() with a pool that has
allowCoreThreadTimeOut(true) and a 1ms keepAlive. Lucene's
HnswConcurrentMergeBuilder uses invokeAll which blocks until all tasks
complete, so threads are guaranteed busy for the entire merge. The 1ms
keepAlive reclaims them almost immediately after each merge finishes.

Includes unit tests verifying thread culling, survival during active
work, GC eligibility of executor objects, and an integration test
exercising real Lucene HNSW merges with a short timeout.

Signed-off-by: Ian Dees <iand@ziprecruiter.com>
2026-09-10 15:04:48 -07:00
.github Add SPDX license header checker and missing headers (#3532) 2026-09-04 08:47:06 -07:00
.idea Add simple IntelliJ debugger config (#2287) 2024-11-25 23:19:54 -08:00
benchmarks Remove benchmarks folder from k-NN repo (#2127) 2024-09-19 09:33:09 -07:00
build-tools Add ci.opensearch.org/m2/ mirror for plugin resolution (k-NN) (#3473) (#3476) 2026-07-31 17:42:14 -04:00
buildSrc Switch checkstyle to spotless (#297) 2022-02-18 09:41:38 -08:00
gradle Guard eclipse() to spotless tasks and keep P2 mirror on pinned version (k-NN) (#3546) 2026-09-03 11:18:00 -07:00
jni Add native SIMD cosine scoring for FP16 and SQ formats, removing post-hoc score conversion (#3386) 2026-09-08 15:38:29 -07:00
qa Add multi-bit SQ (bits ∈ {2, 4}) for Faiss, and make method=flat engine-agnostic with x16 / x8 support (#3544) 2026-09-02 19:57:56 -07:00
release-notes [AUTO] Add release notes for 3.8.0 (#3444) 2026-07-29 12:04:01 -07:00
remote-index-build-client Guard eclipse() to spotless tasks and keep P2 mirror on pinned version (k-NN) (#3546) 2026-09-03 11:18:00 -07:00
sandbox Add Intel SVS (Scalable Vector Search) as a sandbox tenant engine (#3551) 2026-09-08 15:37:22 -07:00
scripts Add SPDX license header checker and missing headers (#3532) 2026-09-04 08:47:06 -07:00
src Fix native thread leak in Lucene HNSW merge executor (#3102) (#3533) 2026-09-10 15:04:48 -07:00
.codecov.yml Fix KNN build and run due to Lucene upgrade 10.4.0 (#3135) 2026-03-05 16:48:51 -08:00
.gitignore Clean JNI artifacts with ./gradlew clean (#2516) 2025-02-11 00:21:00 -06:00
.gitmodules Add faiss support in jni (#28) 2021-10-22 14:47:59 -07:00
.licenserc.json Add SPDX license header checker and missing headers (#3532) 2026-09-04 08:47:06 -07:00
.whitesource Add .whitesource configuration file (#249) 2022-01-06 11:55:57 -08:00
ADMINS.md Add ADMINS.md 2021-06-23 15:48:16 -07:00
build.gradle Guard eclipse() to spotless tasks and keep P2 mirror on pinned version (k-NN) (#3546) 2026-09-03 11:18:00 -07:00
CHANGELOG.md Fix native thread leak in Lucene HNSW merge executor (#3102) (#3533) 2026-09-10 15:04:48 -07:00
CODE_OF_CONDUCT.md Update CODE_OF_CONDUCT 2021-04-16 09:14:53 -07:00
CONTRIBUTING.md Clarify changelog expectations for release notes (#3380) 2026-07-06 16:13:40 -07:00
DEVELOPER_GUIDE.md Added support for 1 bit SQ with remote build (#3270) 2026-04-17 13:59:55 -07:00
gradle.properties Bump default bwc version to 1.3.4 (#477) 2022-07-28 16:12:13 -07:00
GRADLE_GRAPH.md Added new gradle task validateLibraryUsage so that System.loadLibrary cannot be run outside of KNNLibraryLoader (#3033) 2025-12-18 13:29:55 -08:00
gradlew Gradle 9.2.0 and GitHub Actions JDK 25 Upgrade (#2984) 2025-11-24 14:21:25 -08:00
gradlew.bat Gradle 9.2.0 and GitHub Actions JDK 25 Upgrade (#2984) 2025-11-24 14:21:25 -08:00
LICENSE.txt Add windows support (#583) (#599) 2022-10-28 15:59:52 -05:00
lombok.config Adding lombok support (#393) 2022-05-11 17:15:32 -07:00
MAINTAINERS.md Adding kotwanikunal was the maintainer for KNN plugin (#3410) 2026-06-30 18:15:23 -04:00
NOTICE.txt Update license headers (#194) 2021-11-09 18:26:35 -06:00
README.md Update README.md (#2821) 2025-08-04 13:10:00 -04:00
RELEASING.md Refactor BWC framework into sub-projects (#362) 2022-04-18 11:11:59 -05:00
RFC.md Fix invalid url 2021-09-10 14:53:18 -07:00
SECURITY.md Updating security reachout email (#1700) 2024-05-15 09:23:06 -07:00
settings.gradle Add Intel SVS (Scalable Vector Search) as a sandbox tenant engine (#3551) 2026-09-08 15:37:22 -07:00
TRIAGING.md Update TRIAGING.md (#2749) 2025-06-12 18:43:33 -04:00

Build and Test k-NN codecov Documentation Chat PRs welcome!

OpenSearch k-NN

Welcome!

OpenSearch k-NN enables you to run the nearest neighbor search on billions of documents across thousands of dimensions with the same ease as running any regular OpenSearch query. You can use aggregations and filter clauses to further refine your similarity search operations. k-NN similarity search powers use cases such as product recommendations, fraud detection, image and video search, related document search, and more.

Project Resources

Credits and Acknowledgments

This project uses two similarity search libraries to perform Approximate Nearest Neighbor Search: the Apache 2.0-licensed Non-Metric Space Library and the MIT licensed Faiss library. Thank you to all who have contributed to those projects including Bilegsaikhan Naidan, Leonid Boytsov, Yury Malkov and David Novak for nmslib and Hervé Jégou, Matthijs Douze, Jeff Johnson and Lucas Hosseini for Faiss.

Code of Conduct

This project has adopted the Amazon Open Source Code of Conduct. For more information see the Code of Conduct FAQ, or contact opensource-codeofconduct@amazon.com with any additional questions or comments.

License

This project is licensed under the Apache v2.0 License.

Copyright OpenSearch Contributors. See NOTICE for details.