Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit d6bfeba

Browse files
committed
Update index.md
1 parent 08749a5 commit d6bfeba

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/knn/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Short for its associated *k-nearest neighbors* algorithm, the KNN plugin lets yo
1313

1414
## Get started
1515

16-
To use the KNN query type, you must create an index with the `index.knn` setting and add one or more fields of the `knn_vector` data type. Additionally, you can specify the `index.knn.space_type` with `l2` or `cosinesimil` to use, respectively, either Euclidean distance or cosine similarity for calculations. By default, `index.knn.space_type` is `l2`. Here is an example that creates an index with two knn_vector fields and uses cosine similarity:
16+
To use the KNN query type, you must create an index with `index.knn: true` and add one or more fields of the `knn_vector` data type. Additionally, you can specify the `index.knn.space_type` parameter with `l2` or `cosinesimil` to use, respectively, either Euclidean distance or cosine similarity for calculations. By default, `index.knn.space_type` is `l2`. Here is an example that creates an index with two `knn_vector` fields and uses cosine similarity:
1717

1818
```json
1919
PUT my-knn-index-1
@@ -89,9 +89,9 @@ GET my-knn-index-1/_search
8989
In this case, `k` is the number of neighbors you want the query to return, but you must also include the `size` option. Otherwise, you get `k` results for each shard (and each segment) rather than `k` results for the entire query. The plugin supports a maximum `k` value of 10,000.
9090

9191

92-
## Mixing queries
92+
## Compound queries with KNN
9393

94-
If you use the `knn` query alongside filters, you might receive fewer than `k` results. In this example, `post_filter` reduces the number of results from 2 to 1:
94+
If you use the `knn` query alongside filters or other clauses (e.g. `bool`, `must`, `match`), you might receive fewer than `k` results. In this example, `post_filter` reduces the number of results from 2 to 1:
9595

9696
```json
9797
GET my-knn-index-1/_search
@@ -143,7 +143,7 @@ PUT my-knn-index-2
143143
}
144144
```
145145

146-
If you *only* want to use KNN's custom scoring, you can omit `"index.knn": true`, but you lose the ability to perform standard KNN queries on the index. The benefit of this approach is faster indexing speed and lower memory usage.
146+
If you *only* want to use KNN's custom scoring, you can omit `"index.knn": true`. The benefit of this approach is faster indexing speed and lower memory usage, but you lose the ability to perform standard KNN queries on the index.
147147
{: .tip}
148148

149149
Then add some documents:
@@ -196,7 +196,7 @@ GET my-knn-index-2/_search
196196
}
197197
```
198198

199-
All options are required.
199+
All parameters are required.
200200

201201
- `lang` is the script type. This value is usually `painless`, but here you must specify `knn`.
202202
- `source` is the name of the stored script, `knn_store`.

0 commit comments

Comments
 (0)