fix: editing a knowledge file on Elasticsearch keeps its old text searchable

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-09-28 09:40:23 +02:00
parent 176d31d1db
commit ebc8e81a3f

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(