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

Commit ebc4924

Browse files
authored
Merge pull request #247 from jmazanec15/knn-update-1.8
Knn update 1.8
2 parents 5fd4ec9 + d2df4ca commit ebc4924

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

docs/knn/index.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ has_toc: false
88

99
# KNN
1010

11-
Short for its associated *k-nearest neighbors* algorithm, the KNN plugin lets you search for points in a vector space and find the "nearest neighbors" for those points by Euclidean distance. Use cases include recommendations (for example, an "other songs you might like" feature in a music application), image recognition, and fraud detection. For background information on the algorithm, see [Wikipedia](https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm).
11+
Short for its associated *k-nearest neighbors* algorithm, the KNN plugin lets you search for points in a vector space and find the "nearest neighbors" for those points by Euclidean distance or cosine similarity. Use cases include recommendations (for example, an "other songs you might like" feature in a music application), image recognition, and fraud detection. For background information on the algorithm, see [Wikipedia](https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm).
1212

1313

1414
## Get started
1515

16-
To use the KNN plugin, you must create an index with the `index.knn` setting and add one or more fields of the `knn_vector` data type:
16+
To use the KNN plugin, 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`, respectively, to use either Euclidean distance or cosine similarity for calculations. By default, `index.knn.space_type` is set to `l2`. Here is an example that creates an index with two knn_vector fields and uses cosine similarity:
1717

1818
```json
1919
PUT my-index
2020
{
2121
"settings": {
22-
"index.knn": true
22+
"index": {
23+
"knn": true,
24+
"knn.space_type": "cosinesimil"
25+
}
2326
},
2427
"mappings": {
2528
"properties": {

docs/knn/settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Setting | Default | Description
1919
`index.knn.algo_param.ef_search` | 512 | The size of the dynamic list used during KNN searches. Higher values lead to more accurate, but slower searches.
2020
`index.knn.algo_param.ef_construction` | 512 | The size of the dynamic list used during KNN graph creation. Higher values lead to a more accurate graph, but slower indexing speed.
2121
`index.knn.algo_param.m` | 16 | The number of bidirectional links that the plugin creates for each new element. Increasing and decreasing this value can have a large impact on memory consumption. Keep this value between 2-100.
22+
`index.knn.space_type` | "l2" | The vector space used to calculate the distance between vectors. Currently, the KNN plugin supports the `l2` space (Euclidean distance) and `cosinesimil` space (cosine similarity). For more information on these spaces, refer to the [NMSLIB documentation](https://github.com/nmslib/nmslib/blob/master/manual/spaces.md).
2223

2324

2425
## Cluster settings

0 commit comments

Comments
 (0)