Batch sparse search using cosdata client
(name, batch, top_k=10, early_terminate_threshold=0.0)
| 127 | |
| 128 | |
| 129 | def 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 | |
| 146 | def generate_random_sparse_vector(id, dimension, non_zero_dims): |
nothing calls this directly
no test coverage detected