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

Function search_sparse_vector

tests/test-usv.py:114–126  ·  view source on GitHub ↗

Search sparse vector

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

Source from the content-addressed store, hash-verified

112
113
114def search_sparse_vector(name, query_terms, top_k=10, early_terminate_threshold=0.0):
115 """Search sparse vector"""
116 # query_terms should already be in the correct format from format_for_server_query
117 url = f"{client.base_url}/collections/{name}/search/usv"
118 data = {
119 "query_terms": query_terms,
120 "top_k": top_k,
121 "early_terminate_threshold": early_terminate_threshold
122 }
123 response = requests.post(url, headers=client._get_headers(), data=json.dumps(data), verify=client.verify_ssl)
124 if response.status_code != 200:
125 raise Exception(f"Failed to search: {response.text}")
126 return response.json()
127
128
129def batch_ann_search(name, batch, top_k=10, early_terminate_threshold=0.0):

Callers 1

mainFunction · 0.70

Calls 1

_get_headersMethod · 0.45

Tested by

no test coverage detected