Saiteja Solleti commited on
Commit
bf6c451
·
1 Parent(s): 55915f0

addded process time print for search milvus

Browse files
Files changed (1) hide show
  1. searchmilvushelper.py +12 -0
searchmilvushelper.py CHANGED
@@ -1,5 +1,6 @@
1
  #Search Milvus by generating an embedding for the query text. Returns the top_k most similar documents.
2
  #Retrieves all columns defined in the Milvus schema.
 
3
 
4
  def SearchTopKDocuments(collection, query_text, model, top_k=10):
5
 
@@ -12,6 +13,10 @@ def SearchTopKDocuments(collection, query_text, model, top_k=10):
12
  "params": {"ef": 64} # Controls recall, higher values = better accuracy but slower
13
  }
14
 
 
 
 
 
15
  # Perform the search
16
  results = collection.search(
17
  data=[query_embedding],
@@ -31,6 +36,13 @@ def SearchTopKDocuments(collection, query_text, model, top_k=10):
31
  ]
32
  )
33
 
 
 
 
 
 
 
 
34
  # Process and return the results
35
  top_documents = []
36
  for hits in results:
 
1
  #Search Milvus by generating an embedding for the query text. Returns the top_k most similar documents.
2
  #Retrieves all columns defined in the Milvus schema.
3
+ import time
4
 
5
  def SearchTopKDocuments(collection, query_text, model, top_k=10):
6
 
 
13
  "params": {"ef": 64} # Controls recall, higher values = better accuracy but slower
14
  }
15
 
16
+ # Start timing
17
+ start_time = time.time()
18
+
19
+
20
  # Perform the search
21
  results = collection.search(
22
  data=[query_embedding],
 
36
  ]
37
  )
38
 
39
+ # End timing
40
+ end_time = time.time()
41
+
42
+ # Print process time
43
+ process_time = end_time - start_time
44
+ print(f"Milvus Search process completed in {process_time:.4f} seconds.")
45
+
46
  # Process and return the results
47
  top_documents = []
48
  for hits in results: