MCPcopy Create free account
hub / github.com/cosdata/cosdata / batch_ann_search

Function batch_ann_search

tests/test-usv.py:129–143  ·  view source on GitHub ↗

Batch sparse search using cosdata client

(name, batch, top_k=10, early_terminate_threshold=0.0)

Source from the content-addressed store, hash-verified

127
128
129def batch_ann_search(name, batch, top_k=10, early_terminate_threshold=0.0):
130 """Batch sparse search using cosdata client"""
131 try:
132 url = f"{client.base_url}/collections/{name}/search/batch-usv"
133 data = {
134 "query_terms_list": batch,
135 "top_k": top_k,
136 "early_terminate_threshold": early_terminate_threshold
137 }
138 response = requests.post(url, headers=client._get_headers(), data=json.dumps(data), verify=client.verify_ssl)
139 if response.status_code != 200:
140 raise Exception(f"Failed to search: {response.text}")
141 return response.json()
142 except Exception as e:
143 print(f"Error in batch search: {e}")
144
145
146def generate_random_sparse_vector(id, dimension, non_zero_dims):

Callers

nothing calls this directly

Calls 1

_get_headersMethod · 0.45

Tested by

no test coverage detected