Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds documentation for dynamic query parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Tejas Shah <shatejas@amazon.com>
shatejas committed Jul 17, 2024
1 parent e05b400 commit b782565
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion _search-plugins/knn/approximate-knn.md
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ The following table provides examples of the number of results returned by vario
10 | 1 | 1 | 4 | 4 | 1
10 | 10 | 1 | 4 | 10 | 10
10 | 1 | 2 | 4 | 8 | 2

The number of results returned by Faiss/NMSLIB differs from the number of results returned by Lucene only when `k` is smaller than `size`. If `k` and `size` are equal, all engines return the same number of results.

Starting in OpenSearch 2.14, you can use `k`, `min_score`, or `max_distance` for [radial search]({{site.url}}{{site.baseurl}}/search-plugins/knn/radial-search-knn/).
@@ -256,6 +256,50 @@ POST _bulk

After data is ingested, it can be search just like any other `knn_vector` field!

### Additional query parameters
Starting with version 2.16, k-NN plugin supports additional method parameters to tune search results. This can be done by providing the right values in `method_parameters` section of the query. Here is an example of the query

```json
GET my-knn-index-1/_search
{
"size": 2,
"query": {
"knn": {
"my_vector2": {
"vector": [2, 3, 5, 6],
"k": 2,
"method_parameters" : {
"ef_search": 100
}
}
}
}
}
```
These parameters are dependent on the combination of engine and method used to build the index. The tables will help with the valid set of parameters. Invalid combination of parameters will throw an error

#### HNSW

`ef_search`

Explores the `ef_search` number of vectors to find top k nearest neighbors. Higher value will help improve recall at the cost of search latency. The value must be greater than 0

Supported engines | Radial query support | Notes
:--- | :--- | :---

Check failure on line 288 in _search-plugins/knn/approximate-knn.md

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.Spelling] Error: Nmslib. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks. Raw Output: {"message": "[OpenSearch.Spelling] Error: Nmslib. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_search-plugins/knn/approximate-knn.md", "range": {"start": {"line": 288, "column": 1}}}, "severity": "ERROR"}
Nmslib | no | Overrides the value in index settings if present in search query
Faiss | yes | Overrides the value in index settings if present in search query
Lucene | no | Engine supports `k` or `ef_search`. The final result can be controlled by `size`. k-NN plugin will pick `max(k, ef_search)`

#### IVF

`nprobes`

Explores `nprobes` number of clusters to find the top k nearest neighbors. Higher value will help improve recall at the cost of search latency. The value must be greater than 0

Supported engines | Notes
:--- | :---
faiss | Overrides the value in index settings if present in search query

### Using approximate k-NN with filters

To learn about using filters with k-NN search, see [k-NN search with filters]({{site.url}}{{site.baseurl}}/search-plugins/knn/filter-search-knn/).

0 comments on commit b782565

Please sign in to comment.