Skip to content

Commit

Permalink
time logging and grpc for neural search
Browse files Browse the repository at this point in the history
  • Loading branch information
generall committed Oct 21, 2023
1 parent 3b6a330 commit cc1ca8a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion qdrant_demo/neural_searcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from typing import List

from qdrant_client import QdrantClient
Expand All @@ -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]

0 comments on commit cc1ca8a

Please sign in to comment.