Skip to content

Commit

Permalink
Updated readme [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Sep 3, 2024
1 parent 2a4ffc0 commit 6b55390
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,19 @@ Product.search("san", fields: ["store.city"], where: {"store.zip_code" => 12345}
## Nearest Neighbors
You can use custom mapping and searching to index vectors and perform k-nearest neighbor search. See the examples for [Elasticsearch](examples/elasticsearch_knn.rb) and [OpenSearch](examples/opensearch_knn.rb).
For Elasticsearch 8.6+ and OpenSearch 2.4+, use:
```ruby
class Product < ApplicationRecord
searchkick knn: {embedding: {dimensions: 3}}
end
```
Reindex and search with:
```ruby
Product.search(knn: {field: :embedding, vector: [1, 2, 3]})
```
## Reference
Expand Down

0 comments on commit 6b55390

Please sign in to comment.