fix: editing a knowledge file on Elasticsearch keeps its old text searchable (#31530)

With VECTOR_DB=elasticsearch, changing a file's content in a knowledge base added the new text but never removed the old chunks, so searches and chats kept returning the old text next to the new. The old chunks are now found and removed after the edit, the same as on the default store.

Fixes #31523
This commit is contained in:
Classic298 2026-10-01 05:36:44 +02:00 • committed by GitHub
parent e88e1f8119
commit 7cf35bedc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -200,9 +200,9 @@ class ElasticsearchClient(VectorDBBase):
}
for field, value in filter.items():
query_body['query']['bool']['filter'].append({'term': {field: value}})
query_body['query']['bool']['filter'].append({'term': {f'metadata.{field}': value}})
query_body['query']['bool']['filter'].append({'term': {'collection': collection_name}})
size = limit if limit else 10
size = limit if limit else 10000
try:
result = self.client.search(