Skip to content

[DOCS] Add high-level guide for kNN search #80857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/reference/images/kNN/knn_diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions docs/reference/mapping/types/dense-vector.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ It is not possible to store multiple values in one `dense_vector` field.

experimental::[]

A _k-nearest neighbor_ (kNN) search finds the _k_ nearest
vectors to a query vector, as measured by a similarity metric.
include::{es-repo-dir}/search/search-your-data/run-knn-search.asciidoc[tag=knn-def]

Dense vector fields can be used to rank documents in
<<query-dsl-script-score-query,`script_score` queries>>. This lets you perform
Expand Down Expand Up @@ -92,11 +91,13 @@ PUT my-index-2
efficient kNN search. Like most kNN algorithms, HNSW is an approximate method
that sacrifices result accuracy for improved speed.

NOTE: Indexing vectors for approximate kNN search is an expensive process. It can take
substantial time to ingest documents that contain vector fields with `index`
enabled.
//tag::dense-vector-indexing-speed[]
NOTE: Indexing vectors for approximate kNN search is an expensive process. It
can take substantial time to ingest documents that contain vector fields with
`index` enabled.
//end::dense-vector-indexing-speed[]

NOTE: Dense vector fields cannot be indexed if they are within
Dense vector fields cannot be indexed if they are within
<<nested, `nested`>> mappings.

[role="child_attributes"]
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/search/knn-search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ The kNN search API performs a k-nearest neighbor (kNN) search on a
<<dense-vector,`dense_vector`>> field. Given a query vector, it finds the _k_
closest vectors and returns those documents as search hits.

//tag::hnsw-algorithm[]
{es} uses the https://arxiv.org/abs/1603.09320[HNSW algorithm] to support
efficient kNN search. Like most kNN algorithms, HNSW is an approximate method
that sacrifices result accuracy for improved search speed. This means the
results returned are not always the true _k_ closest neighbors.
//end::hnsw-algorithm[]

[[knn-search-api-path-params]]
==== {api-path-parms-title}
Expand Down
Loading