From 7cf35bedc06207ea9f15f7fdf2cd33dda2d14e19 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 1 Oct 2026 05:36:44 +0200 Subject: [PATCH] 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 --- backend/open_webui/retrieval/vector/dbs/elasticsearch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/retrieval/vector/dbs/elasticsearch.py b/backend/open_webui/retrieval/vector/dbs/elasticsearch.py index f8178bdbac..ca9eb1e08c 100644 --- a/backend/open_webui/retrieval/vector/dbs/elasticsearch.py +++ b/backend/open_webui/retrieval/vector/dbs/elasticsearch.py @@ -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(