Merge pull request #19025 from krishna-medapati/fix-hybrid-search-17046-clean

fix: Handle AttributeError in hybrid search with reranking (#17046)
This commit is contained in:
Tim Baek 2025-11-09 20:43:52 -05:00 committed by GitHub
commit 284764e178
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -160,10 +160,18 @@ def query_doc_with_hybrid_search(
hybrid_bm25_weight: float, hybrid_bm25_weight: float,
) -> dict: ) -> dict:
try: try:
# First check if collection_result has the required attributes
if ( if (
not collection_result not collection_result
or not hasattr(collection_result, "documents") or not hasattr(collection_result, "documents")
or not collection_result.documents or not hasattr(collection_result, "metadatas")
):
log.warning(f"query_doc_with_hybrid_search:no_docs {collection_name}")
return {"documents": [], "metadatas": [], "distances": []}
# Now safely check the documents content after confirming attributes exist
if (
not collection_result.documents
or len(collection_result.documents) == 0 or len(collection_result.documents) == 0
or not collection_result.documents[0] or not collection_result.documents[0]
): ):