fix: Lindorm vector store errors caused by the update of opensearch-py (#37862)

This commit is contained in:
Jiang 2026-06-24 17:54:06 +08:00 committed by GitHub
parent ea1aa2fecd
commit d135dab241
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -113,7 +113,7 @@ class LindormVectorStore(BaseVector):
)
def _bulk_with_retry(actions):
try:
response = self._client.bulk(actions, timeout=timeout)
response = self._client.bulk(body=actions, timeout=timeout)
if response["errors"]:
error_items = [item for item in response["items"] if "error" in item["index"]]
error_msg = f"Bulk indexing had {len(error_items)} errors"
@ -231,7 +231,7 @@ class LindormVectorStore(BaseVector):
routing_filter_query = {
"query": {"bool": {"must": [{"term": {f"{ROUTING_FIELD}.keyword": self._routing}}]}}
}
self._client.delete_by_query(self._collection_name, body=routing_filter_query)
self._client.delete_by_query(index=self._collection_name, body=routing_filter_query)
self.refresh()
else:
if self._client.indices.exists(index=self._collection_name):

View File

@ -127,7 +127,7 @@ def test_create_refresh_and_add_texts_success(lindorm_module, monkeypatch: pytes
vector.add_texts(docs, embeddings, batch_size=2, timeout=9)
assert vector._client.bulk.call_count == 2
actions = vector._client.bulk.call_args_list[0].args[0]
actions = vector._client.bulk.call_args_list[0].kwargs["body"]
assert actions[0]["index"]["routing"] == "route"
assert actions[1][lindorm_module.ROUTING_FIELD] == "route"
vector.refresh()