Skip to content

Commit

Permalink
Es knn index search 5346 (langchain-ai#5569)
Browse files Browse the repository at this point in the history
# Create elastic_vector_search.ElasticKnnSearch class

This extends `langchain/vectorstores/elastic_vector_search.py` by adding
a new class `ElasticKnnSearch`

Features:
- Allow creating an index with the `dense_vector` mapping compataible
with kNN search
- Store embeddings in index for use with kNN search (correct mapping
creates HNSW data structure)
- Perform approximate kNN search
- Perform hybrid BM25 (`query{}`) + kNN (`knn{}`) search
- perform knn search by either providing a `query_vector` or passing a
hosted `model_id` to use query_vector_builder to automatically generate
a query_vector at search time

Connection options
- Using `cloud_id` from Elastic Cloud
- Passing elasticsearch client object

search options
- query
- k
- query_vector
- model_id
- size
- source
- knn_boost (hybrid search)
- query_boost (hybrid search)
- fields


This also adds examples to
`docs/modules/indexes/vectorstores/examples/elasticsearch.ipynb`


Fixes # [5346](langchain-ai#5346)

cc: @dev2049

 -->

---------

Co-authored-by: Dev 2049 <[email protected]>
  • Loading branch information
jeffvestal and dev2049 authored Jun 2, 2023
1 parent 8b3df18 commit d1f65d8
Show file tree
Hide file tree
Showing 3 changed files with 830 additions and 236 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,7 @@ wandb/

# integration test artifacts
data_map*
\[('_type', 'fake'), ('stop', None)]
\[('_type', 'fake'), ('stop', None)]

# Replit files
*replit*
Loading

0 comments on commit d1f65d8

Please sign in to comment.