Repository navigation
Conversation
…shold filter Hybrid search defers score thresholding to the post-retrieval stage (langgenius#35233), so the vector store returns all candidates with embedding_score_threshold=0.0. When no rerank runner is configured, _filter_documents_by_vector_score_threshold filtered the merged candidates by their stored metadata score. Full-text search results carry no metadata score, so the get("score", 0) default treated every one of them as below any positive threshold and silently dropped them. With score_threshold enabled, hybrid search returned 0 results while vector and full-text search each worked correctly. Keep documents that have no stored score: the threshold cannot be evaluated for them, so they pass through instead of being dropped. Scored documents (vector candidates) are still filtered as before, and when a rerank runner exists the filter is skipped entirely, so reranking behavior is unchanged. Regression tests cover the filter helper directly and the hybrid _retrieve flow both without and with a rerank runner. Fixes langgenius#47357
Pyrefly Type Coverage
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #47411 +/- ##
==========================================
- Coverage 90.62% 90.62% -0.01%
==========================================
Files 6665 6665
Lines 415339 415343 +4
Branches 83296 83297 +1
==========================================
+ Hits 376412 376413 +1
- Misses 32541 32544 +3
Partials 6386 6386
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Updated in |
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-11-28 10:00:29.277910340 +0000
+++ /tmp/pyrefly_pr.txt 2026-11-28 10:00:18.245820481 +0000
@@ -3819,7 +3819,7 @@
ERROR Argument `dict[str, str]` is not assignable to parameter `reranking_model` with type `RerankingModelDict | None` in function `core.rag.data_post_processor.data_post_processor.DataPostProcessor._get_rerank_model_instance` [bad-argument-type]
--> tests/unit_tests/core/rag/data_post_processor/test_data_post_processor.py:192:33
ERROR Argument `str` is not assignable to parameter `doc_form` with type `IndexStructureType | SQLCoreOperations[IndexStructureType]` in function `models.dataset.Document.__init__` [bad-argument-type]
- --> tests/unit_tests/core/rag/datasource/test_retrieval_service.py:148:18
+ --> tests/unit_tests/core/rag/datasource/test_retrieval_service.py:149:18
ERROR Argument `list[FromClause]` is not assignable to parameter `tables` with type `Sequence[Table] | None` in function `sqlalchemy.sql.schema.MetaData.create_all` [bad-argument-type]
--> tests/unit_tests/core/rag/extractor/test_excel_extractor.py:17:56
ERROR Argument `object | None` is not assignable to parameter `session` with type `Session | None` in function `core.rag.extractor.extract_processor.ExtractProcessor.extract` [bad-argument-type]
|
Summary
score_thresholdenabled returned 0 results in the Retrieval Testing page while Vector search and Full-Text search on the same dataset returned hits (reported in Hybrid Search returns 0 results while Vector and Full-Text Search work correctly (Dify 1.19, Weaviate, Ollama) #47357).embedding_score_threshold = 0.0) and defers thresholding to the merged post-retrieval stage. When no rerank runner is configured,RetrievalService._filter_documents_by_vector_score_thresholdfilters the merged candidates by their storedmetadata["score"]. Full-text search results carry no stored score, sometadata.get("score", 0)evaluated them as0and dropped every full-text candidate whenever a positive threshold was set. Vector results kept their real cosine score, which is why each single method worked but hybrid returned nothing.test_filter_documents_by_vector_score_threshold_keeps_unscored_documentscovers the filter helper directly;test_retrieve_internal_hybrid_keeps_unscored_fulltext_documents_without_rerank_runnerreproduces the 0-result flow end to end;test_retrieve_internal_hybrid_skips_threshold_filter_when_rerank_runner_presentpins the unchanged reranker behavior.Screenshots
N/A (backend fix, verified by unit tests:
42 passedintests/unit_tests/core/rag/datasource/test_retrieval_service.py).Checklist