Coverage for src/qdrant_loader_mcp_server/search/hybrid/adapters.py: 95%
20 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:06 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:06 +0000
1from __future__ import annotations
3from ..components.keyword_search_service import KeywordSearchService
4from ..components.result_combiner import ResultCombiner
5from ..components.vector_search_service import VectorSearchService
6from .interfaces import KeywordSearcher, ResultCombinerLike, VectorSearcher
9class VectorSearcherAdapter(VectorSearcher):
10 def __init__(self, service: VectorSearchService):
11 self._service = service
13 async def search(self, query: str, limit: int, project_ids: list[str] | None): # type: ignore[override]
14 return await self._service.vector_search(query, limit, project_ids)
17class KeywordSearcherAdapter(KeywordSearcher):
18 def __init__(self, service: KeywordSearchService):
19 self._service = service
21 async def search(self, query: str, limit: int, project_ids: list[str] | None): # type: ignore[override]
22 return await self._service.keyword_search(query, limit, project_ids)
25class ResultCombinerAdapter(ResultCombinerLike):
26 def __init__(self, combiner: ResultCombiner):
27 self._combiner = combiner
29 async def combine_results( # type: ignore[override]
30 self,
31 vector_results: list[dict],
32 keyword_results: list[dict],
33 query_context: dict,
34 limit: int,
35 source_types: list[str] | None,
36 project_ids: list[str] | None,
37 ):
38 return await self._combiner.combine_results(
39 vector_results,
40 keyword_results,
41 query_context,
42 limit,
43 source_types,
44 project_ids,
45 )