From 8a6111d00d23704d24783d9ac52b0db107611d56 Mon Sep 17 00:00:00 2001 From: pk5ls20 Date: Wed, 3 Jul 2024 01:51:17 +0800 Subject: [PATCH] Fix the issue of incorrect vector returns in combined search --- app/Controllers/search.py | 2 +- app/Services/vector_db_context.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Controllers/search.py b/app/Controllers/search.py index e5da50f..911d803 100644 --- a/app/Controllers/search.py +++ b/app/Controllers/search.py @@ -204,7 +204,7 @@ def calculate_and_sort_by_combined_scores(model: CombinedSearchModel, case SearchBasisEnum.ocr: extra_vector = itm.img.image_vector case SearchBasisEnum.vision: - extra_vector = itm.img.text_contain_vector if itm.img.text_contain_vector else None + extra_vector = itm.img.text_contain_vector case _: # pragma: no cover raise NotImplementedError() if extra_vector is not None: diff --git a/app/Services/vector_db_context.py b/app/Services/vector_db_context.py index 8f68467..e1a0f27 100644 --- a/app/Services/vector_db_context.py +++ b/app/Services/vector_db_context.py @@ -127,7 +127,7 @@ async def querySimilar(self, mode == SearchModelEnum.average else RecommendStrategy.BEST_SCORE) # since only combined_search need return vectors, We can define _combined_search_need_vectors like below _combined_search_need_vectors = [ - self.IMG_VECTOR if query_vector_name == self.TEXT_VECTOR else self.IMG_VECTOR] if with_vectors else None + self.IMG_VECTOR if query_vector_name == self.TEXT_VECTOR else self.TEXT_VECTOR] if with_vectors else None logger.info("Querying Qdrant... top_k = {}", top_k) result = await self._client.recommend(collection_name=self.collection_name, using=query_vector_name,