[Fix] add documentation regarding usage of filter/post_filter in k-NN… (#4494)
* [Fix] add documentation regarding usage of filter/post_filter in k-NN plugin Signed-off-by: jiapinw <jiapinw@amazon.com> * Revise doc update based on comments and offline discussions Signed-off-by: jiapinw <jiapinw@amazon.com> * Update doc based on comments Signed-off-by: jiapinw <jiapinw@amazon.com> * Update _search-plugins/knn/filter-search-knn.md Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: jiapinw <jiapinw@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
This commit is contained in:
parent
d78bd5b70e
commit
44e397c932
|
@ -17,6 +17,7 @@ To refine k-NN results, you can filter a k-NN search using one of the following
|
||||||
|
|
||||||
- [Lucene k-NN filter](#using-a-lucene-k-nn-filter): This approach applies filtering _during_ the k-NN search, as opposed to before or after the k-NN search, which ensures that `k` results are returned. You can only use this method with the Hierarchical Navigable Small World (HNSW) algorithm implemented by the Lucene search engine in k-NN plugin versions 2.4 and later.
|
- [Lucene k-NN filter](#using-a-lucene-k-nn-filter): This approach applies filtering _during_ the k-NN search, as opposed to before or after the k-NN search, which ensures that `k` results are returned. You can only use this method with the Hierarchical Navigable Small World (HNSW) algorithm implemented by the Lucene search engine in k-NN plugin versions 2.4 and later.
|
||||||
|
|
||||||
|
|
||||||
## Filtered search optimization
|
## Filtered search optimization
|
||||||
|
|
||||||
Depending on your dataset and use case, you might be more interested in maximizing recall or minimizing latency. The following table provides guidance on various k-NN search configurations and the filtering methods used to optimize for higher recall or lower latency. The first three columns of the table provide several example k-NN search configurations. A search configuration consists of:
|
Depending on your dataset and use case, you might be more interested in maximizing recall or minimizing latency. The following table provides guidance on various k-NN search configurations and the filtering methods used to optimize for higher recall or lower latency. The first three columns of the table provide several example k-NN search configurations. A search configuration consists of:
|
||||||
|
@ -197,6 +198,8 @@ The response includes documents containing the matching hotels:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The location of the `filter` clause matters when it's used with a k-NN query clause. If the `filter` clause is outside the k-NN query clause, it must be a leaf clause. In this case, the filter is applied after the k-NN search and works exactly like the `post_filter` keyword. If the `filter` clause is within the k-NN query clause, it works as a hybrid of pre- and post-filtering (this option is only supported for the Lucene search engine).
|
||||||
|
|
||||||
## Lucene k-NN filter implementation
|
## Lucene k-NN filter implementation
|
||||||
|
|
||||||
k-NN plugin version 2.2 introduced support for running k-NN searches with the Lucene engine using HNSW graphs. Starting with version 2.4, which is based on Lucene version 9.4, you can use Lucene filters for k-NN searches.
|
k-NN plugin version 2.2 introduced support for running k-NN searches with the Lucene engine using HNSW graphs. Starting with version 2.4, which is based on Lucene version 9.4, you can use Lucene filters for k-NN searches.
|
||||||
|
|
Loading…
Reference in New Issue