- Java 91%
- C++ 8.3%
- CMake 0.4%
- C 0.2%
A knn query vector with a NaN or infinite component reached native engine code unvalidated. Neither nmslib's HNSW sort comparator nor Faiss's MinimaxHeap is NaN-safe, so one such search segfaulted the node (any user with search access could crash it). Indexing already rejected NaN/Infinity; only the query paths did not. Reject non-finite query vector components on both query paths, for every engine: - KNNQueryBuilder.doToQuery: the float-vector branch now calls KNNValidationUtil.validateFloatVectorValue(float[]), the same NaN/Infinity check the byte/binary branches already run via validateByteVectorValue. This is the single chokepoint every knn query (k-NN and radial) and every engine funnels through before native search. - KNNScoringSpaceUtil.convertVectorToPrimitive: the float knn_score path rejects NaN/Infinity too, so it returns a 4xx instead of NaN scores. knn_score has its own vector parse and does not pass through doToQuery. KNNValidationUtil gains a validateFloatVectorValue(float[]) overload (null is a no-op, otherwise each component is checked) so callers validate a whole vector in one call. Tests: - KNNValidationUtilTests: the float[] overload for all-finite, NaN and infinity. - KNNQueryBuilderTests: NaN and infinite float query vectors are rejected at doToQuery. - KNNScriptScoringIT: knn_score rejects a non-finite vector with 4xx. - NonFiniteQueryVectorIT (new): per engine a finite query returns 200, NaN and 1e39 query vectors return 400, and a finite query still returns 200 afterwards; nmslib is skipped where new-index creation is deprecated (3.0+). Signed-off-by: Vikash Tiwari <viktari@amazon.com> |
||
|---|---|---|
| .github | ||
| .idea | ||
| benchmarks | ||
| build-tools | ||
| buildSrc | ||
| gradle | ||
| jni | ||
| qa | ||
| release-notes | ||
| remote-index-build-client | ||
| sandbox | ||
| scripts | ||
| src | ||
| .codecov.yml | ||
| .gitignore | ||
| .gitmodules | ||
| .licenserc.json | ||
| .whitesource | ||
| ADMINS.md | ||
| build.gradle | ||
| CHANGELOG.md | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| DEVELOPER_GUIDE.md | ||
| gradle.properties | ||
| GRADLE_GRAPH.md | ||
| gradlew | ||
| gradlew.bat | ||
| LICENSE.txt | ||
| lombok.config | ||
| MAINTAINERS.md | ||
| NOTICE.txt | ||
| README.md | ||
| RELEASING.md | ||
| RFC.md | ||
| SECURITY.md | ||
| settings.gradle | ||
| TRIAGING.md | ||
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
- Project Website
- Downloads
- Documentation
- Need help? Try the Forum
- Project Principles
- Contributing to OpenSearch k-NN
- Maintainer Responsibilities
- Release Management
- Admin Responsibilities
- Security
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
Copyright OpenSearch Contributors. See NOTICE for details.