Searches for nearest neighbors in the encrypted index using vector similarity search. Supports single vector queries, batch queries, and semantic search with text content.
Copy
Ask AI
func (e *EncryptedIndex) Query(ctx context.Context, input QueryInput) (*QueryResponse, error)
// 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", "contents"},}results, err := index.Query(context.Background(), params)if err != nil { log.Fatalf("Content search failed: %v", err)}for i, result := range results.Results { 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.