用于 Qdrant 向量搜索引擎的 Go 客户端
Go client for the Qdrant vector search engine.
Go client library with handy utilities for interfacing with Qdrant.
go get -u github.com/qdrant/go-clientA client can be instantiated with
import "github.com/qdrant/go-client/qdrant"
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})Which creates a client that will connect to Qdrant on .
Internally, the high-level client uses a low-level gRPC client to interact with
Qdrant. qdrant.Config provides additional options to control how the gRPC
client is configured. The following example configures API key authentication with TLS:
import "github.com/qdrant/go-client/qdrant"
client, err := qdrant.NewClient(&qdrant.Config{
Host: "xyz-example.eu-central.aws.cloud.qdrant.io",
Port: 6334,
APIKey: "",
UseTLS: true, // uses default config with minimum TLS version set to 1.3
// PoolSize: 3,
// KeepAliveTime: 10,
// KeepAliveTimeout: 2,
// TLSConfig: &tls.Config{...},
// GrpcOptions: []grpc.DialOption{},
})Once a client has been created, create a new collection
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "{collection_name}",
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
Size: 4,
Distance: qdrant.Distance_Cosine,
}),
})Insert vectors into the collection
…Search for similar vectors
searchResult, err := client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
})Search for similar vectors with a filtering condition
searchResult, err := client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
Filter: &qdrant.Filter{
Must: []*qdrant.Condition{
qdrant.NewMatch("city", "London"),
},
},
WithPayload: qdrant.NewWithPayload(true),
})暂无开放 Issues,或尚未同步最近议题。