Skip to content

Commit

Permalink
Add k-NN Faiss filtering documentation (opensearch-project#4476)
Browse files Browse the repository at this point in the history
* Add k-NN Faiss filtering documentation

Signed-off-by: Fanit Kolchina <[email protected]>

* Move the note

Signed-off-by: Fanit Kolchina <[email protected]>

* Add faiss and a filter table

Signed-off-by: Fanit Kolchina <[email protected]>

* Refactor boolean filtering section

Signed-off-by: Fanit Kolchina <[email protected]>

* Clarified that Faiss works with hnsw only

Signed-off-by: Fanit Kolchina <[email protected]>

* Add more Faiss filtering information

Signed-off-by: Fanit Kolchina <[email protected]>

* Apply suggestions from code review

Co-authored-by: Melissa Vagi <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Apply suggestions from code review

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Update _search-plugins/knn/filter-search-knn.md

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Implemented editorial comments

Signed-off-by: Fanit Kolchina <[email protected]>

* Implemented one more editorial comment

Signed-off-by: Fanit Kolchina <[email protected]>

---------

Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
Co-authored-by: Melissa Vagi <[email protected]>
Co-authored-by: Nathan Bower <[email protected]>
  • Loading branch information
3 people authored and harshavamsi committed Oct 31, 2023
1 parent 5f37636 commit 5572a74
Show file tree
Hide file tree
Showing 3 changed files with 409 additions and 198 deletions.
24 changes: 1 addition & 23 deletions _search-plugins/knn/approximate-knn.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,30 +242,8 @@ POST _bulk
After data is ingested, it can be search just like any other `knn_vector` field!

### Using approximate k-NN with filters
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:

```json
GET my-knn-index-1/_search
{
"size": 2,
"query": {
"knn": {
"my_vector2": {
"vector": [2, 3, 5, 6],
"k": 2
}
}
},
"post_filter": {
"range": {
"price": {
"gte": 5,
"lte": 10
}
}
}
}
```
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/).

## Spaces

Expand Down
Loading

0 comments on commit 5572a74

Please sign in to comment.