Golang Qdrant client
Go client for Qdrant vector search engine
Install
go get github.com/qdrant/go-client
Usage
Run Qdrant with enabled gRPC interface:
# With env variable
docker run -p 6333:6333 -p 6334:6334 \
-e QDRANT__SERVICE__GRPC_PORT="6334" \
qdrant/qdrant
Or by updating the configuration file:
service:
grpc_port: 6334
More info about gRPC in documentation.
Making requests
package main
import (
"context"
"flag"
"log"
"time"
pb "github.com/qdrant/go-client/qdrant"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
var (
addr = flag.String("addr", "localhost:6334", "the address to connect to")
)
func main() {
flag.Parse()
// Set up a connection to the server.
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
collections_client := pb.NewCollectionsClient(conn)
// Contact the server and print out its response.
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
r, err := collections_client.List(ctx, &pb.ListCollectionsRequest{})
if err != nil {
log.Fatalf("could not get collections: %v", err)
}
log.Printf("List of collections: %s", r.GetCollections())
}
For authenticated request (using API KEY and TLS) to Qdrant Cloud, please refer to the authenticated example.
A full example for uploading, searching and filtering can be found in the examples
directory.