From cc1ca8a733c0b9384ed63a774f167f756daa5954 Mon Sep 17 00:00:00 2001 From: generall Date: Sat, 21 Oct 2023 13:53:48 +0200 Subject: [PATCH] time logging and grpc for neural search --- qdrant_demo/neural_searcher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qdrant_demo/neural_searcher.py b/qdrant_demo/neural_searcher.py index dba0926..d7b57df 100644 --- a/qdrant_demo/neural_searcher.py +++ b/qdrant_demo/neural_searcher.py @@ -1,3 +1,4 @@ +import time from typing import List from qdrant_client import QdrantClient @@ -10,14 +11,16 @@ class NeuralSearcher: def __init__(self, collection_name: str): self.collection_name = collection_name - self.qdrant_client = QdrantClient(url=QDRANT_URL, api_key=QDRANT_API_KEY) + self.qdrant_client = QdrantClient(url=QDRANT_URL, api_key=QDRANT_API_KEY, prefer_grpc=True) self.qdrant_client.set_model(EMBEDDINGS_MODEL) def search(self, text: str, filter_: dict = None) -> List[dict]: + start_time = time.time() hits = self.qdrant_client.query( collection_name=self.collection_name, query_text=text, query_filter=Filter(**filter_) if filter_ else None, limit=5 ) + print(f"Search took {time.time() - start_time} seconds") return [hit.metadata for hit in hits]