This commit is contained in:
Varsha 2025-10-03 09:01:46 +02:00 committed by GitHub
commit 78750b6c79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 156 additions and 23 deletions

View file

@ -132,13 +132,43 @@ class QdrantIndex(EmbeddingIndex):
return QueryChunksResponse(chunks=chunks, scores=scores)
async def query_keyword(
self,
query_string: str,
k: int,
score_threshold: float,
) -> QueryChunksResponse:
raise NotImplementedError("Keyword search is not supported in Qdrant")
async def query_keyword(self, query_string: str, k: int, score_threshold: float) -> QueryChunksResponse:
try:
results = (
await self.client.query_points(
collection_name=self.collection_name,
query_filter=models.Filter(
must=[
models.FieldCondition(
key="chunk_content.content", match=models.MatchText(text=query_string)
)
]
),
limit=k,
with_payload=True,
with_vectors=False,
score_threshold=score_threshold,
)
).points
except Exception as e:
log.error(f"Error querying keyword search in Qdrant collection {self.collection_name}: {e}")
raise
chunks, scores = [], []
for point in results:
assert isinstance(point, models.ScoredPoint)
assert point.payload is not None
try:
chunk = Chunk(**point.payload["chunk_content"])
except Exception:
log.exception("Failed to parse chunk")
continue
chunks.append(chunk)
scores.append(point.score)
return QueryChunksResponse(chunks=chunks, scores=scores)
async def query_hybrid(
self,