Searches for nearest neighbors in the encrypted index using vector similarity search. Supports single vector queries, batch queries, and semantic search with text content.
func (e *EncryptedIndex) Query(ctx context.Context, input QueryInput) (*QueryResponse, error)
(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
(Optional) Number of nearest neighbors to return (default: 100)
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", "distance", "vector". Defaults to [] (only id is returned). QueryResultItem has no Contents field — to retrieve contents, use Get with the matching IDs after querying.
Greedy
*bool
(Optional) Use greedy search algorithm
RerankMult
*int32
(Optional) Multiplier for stage 1 retrieval in reranking indexes. Stage 1 returns TopK * RerankMult candidates before reranking narrows to TopK. Server default: 10. Ignored by indexes that do not rerank.
Include defaults differ between endpoints: Query returns [] (only Id) by default, while Get returns ["vector", "contents", "metadata"].
// Search using text content (requires embedding model configured on index)textQuery := "machine learning healthcare applications"params := cyborgdb.QueryParams{ QueryContents: &textQuery, TopK: 10, Include: []string{"metadata", "distance"},}results, err := index.Query(context.Background(), params)if err != nil { log.Fatalf("Content search failed: %v", err)}if results.Results.ArrayOfQueryResultItem != nil { for i, result := range *results.Results.ArrayOfQueryResultItem { fmt.Printf("%d. ID: %s, Distance: %.4f\n", i+1, result.Id, result.GetDistance()) if result.Metadata != nil { fmt.Printf(" Metadata: %v\n", result.Metadata) } }}
BinaryQueryParams is available as an alternative to QueryParams that uses binary transfer for large batch queries. This can significantly improve performance when querying with many vectors at once.
BinaryQueryParams does not accept RerankMult — it is supported only on QueryParams. Use QueryParams if you need to tune the stage-1 candidate multiplier on a reranking index.