Parameters
Parameter | Type | Description |
---|---|---|
ctx | context.Context | Context for cancellation and timeouts |
params | QueryParams | Query parameters specifying vectors, filters, and options |
QueryParams
Field | Type | Description |
---|---|---|
QueryVector | []float32 | (Optional) Single query vector for similarity search |
BatchQueryVectors | [][]float32 | (Optional) Multiple query vectors for batch search |
QueryContents | *string | (Optional) Text content for semantic search |
TopK | int32 | Number of nearest neighbors to return (required) |
NProbes | *int32 | (Optional) Number of clusters to probe for search |
Filters | map[string]interface{} | (Optional) Metadata filters to apply |
Include | []string | (Optional) Fields to include in results: “metadata”, “vector”, “contents” |
Greedy | *bool | (Optional) Use greedy search algorithm |
Returns
*QueryResponse
: Search results containing vectors, distances, and requested fieldserror
: Any error encountered during the search operation
Error Handling
API Errors
API Errors
- Returns error if the API request fails due to network connectivity issues
- Returns error if authentication fails (invalid API key)
- Returns error if the encryption key is invalid for the specified index
- Returns error if there are internal server errors during the search
Validation Errors
Validation Errors
- Returns error if none of QueryVector, BatchQueryVectors, or QueryContents is provided
- Returns error if vector dimensions don’t match the index configuration
- Returns error if parameter values are out of valid ranges
- Returns error if the Include parameter contains invalid field names