Skip to content

Commit

Permalink
community: OpenSearchVectorStore: use engine set at init() time by de…
Browse files Browse the repository at this point in the history
…fault (#28147)

Description:
* Updated the OpenSearchVectorStore to use the `engine` parameter
captured at `init()` time as the default when adding documents to the
store.

Formatted, Linted, and Tested.
  • Loading branch information
epinzur authored Nov 16, 2024
1 parent e6fe8cc commit 0a57fc0
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def __init__(
self.is_aoss = _is_aoss_enabled(http_auth=http_auth)
self.client = _get_opensearch_client(opensearch_url, **kwargs)
self.async_client = _get_async_opensearch_client(opensearch_url, **kwargs)
self.engine = kwargs.get("engine")
self.engine = kwargs.get("engine", "nmslib")

@property
def embeddings(self) -> Embeddings:
Expand All @@ -420,7 +420,7 @@ def __add(
index_name = kwargs.get("index_name", self.index_name)
text_field = kwargs.get("text_field", "text")
dim = len(embeddings[0])
engine = kwargs.get("engine", "nmslib")
engine = kwargs.get("engine", self.engine)
space_type = kwargs.get("space_type", "l2")
ef_search = kwargs.get("ef_search", 512)
ef_construction = kwargs.get("ef_construction", 512)
Expand Down Expand Up @@ -461,7 +461,7 @@ async def __aadd(
index_name = kwargs.get("index_name", self.index_name)
text_field = kwargs.get("text_field", "text")
dim = len(embeddings[0])
engine = kwargs.get("engine", "nmslib")
engine = kwargs.get("engine", self.engine)
space_type = kwargs.get("space_type", "l2")
ef_search = kwargs.get("ef_search", 512)
ef_construction = kwargs.get("ef_construction", 512)
Expand Down Expand Up @@ -530,7 +530,7 @@ def create_index(
)

if is_appx_search:
engine = kwargs.get("engine", "nmslib")
engine = kwargs.get("engine", self.engine)
space_type = kwargs.get("space_type", "l2")
ef_search = kwargs.get("ef_search", 512)
ef_construction = kwargs.get("ef_construction", 512)
Expand Down

0 comments on commit 0a57fc0

Please sign in to comment.