Skip to content

Commit

Permalink
fix bes vector store search (langchain-ai#12828)
Browse files Browse the repository at this point in the history
**Issue:** 
fix search body in baidu cloud vectorsearch

---------

Co-authored-by: wemysschen <[email protected]>
  • Loading branch information
wemysschen and wemysschen authored Nov 3, 2023
1 parent f04e4df commit e14aa37
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def bes_client(
connection_params: Dict[str, Any] = {}

connection_params["hosts"] = [bes_url]
connection_params["basic_auth"] = (username, password)
if username and password:
connection_params["basic_auth"] = (username, password)

es_client = elasticsearch.Elasticsearch(**connection_params)
try:
Expand Down Expand Up @@ -236,7 +237,6 @@ def _query_body(

if "linear" == self.index_type:
query_vector_body["linear"] = True
query_vector_body["space_type"] = self.space_type
else:
query_vector_body["ef"] = search_params.get("ef", 10)

Expand Down Expand Up @@ -279,7 +279,7 @@ def _search(
logger.debug(f"Query body: {query_body}")

# Perform the kNN search on the BES index and return the results.
response = self.client.search(index=self.index_name, **query_body)
response = self.client.search(index=self.index_name, body=query_body)
logger.debug(f"response={response}")

hits = [hit for hit in response["hits"]["hits"]]
Expand Down

0 comments on commit e14aa37

Please sign in to comment.