mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 19:38:46 -05:00
[PR #21643] [CLOSED] fix: correct document/metadata swap in hybrid search sort #26178
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21643
Author: @hackwell
Created: 2/20/2026
Status: ❌ Closed
Base:
main← Head:fix/hybrid-search-document-metadata-swap📝 Commits (1)
b3851a8fix: correct document/metadata swap in hybrid search sort📊 Changes
1 file changed (+1 additions, -1 deletions)
View changed files
📝
backend/open_webui/retrieval/utils.py(+1 -1)📄 Description
Summary
documentsandmetadatasvariables inquery_doc_with_hybrid_searchwhenk < k_rerankerProblem
In
backend/open_webui/retrieval/utils.py, line 295, thezip()call used the order(distances, metadatas, documents):But the subsequent unpacking at line 300 expected
(distances, documents, metadatas):This caused
documentsto contain metadata dicts andmetadatasto contain document strings wheneverk < k_reranker(the default config:TOP_K=8,TOP_K_RERANKER=20).Downstream,
merge_and_sort_query_resultschecksisinstance(document, str)which returnedFalsefor the dict objects, silently discarding all hybrid search results.Impact
All hybrid search + reranking results are silently dropped when
TOP_K < TOP_K_RERANKER(the default configuration). The RAG pipeline appears to work (Qdrant returns results, reranker scores them) but no documents reach the model context.Fix
One-character fix: change
zip(distances, metadatas, documents)tozip(distances, documents, metadatas)to match the unpacking order.Test plan
/api/v1/retrieval/query/collection— returns documents with correct typesmerge_and_sort_query_resultsreceives strings in documents field (not dicts)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.