Help us shape the future of Go! Take the 2026 Go Developer Survey

vald-client-go

module
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2022 License: Apache-2.0

README

vald-client-go

release Go Reference Codacy Badge Go Report Card DepShield Badge FOSSA Status DeepSource CLA Slack Twitter

example code
	// Create a Vald clien connection for Vald cluster.
	conn, err := grpc.DialContext(ctx, "addr to cluster", grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}

	// Creates Vald client for gRPC.
	client := vald.NewValdClient(conn)

	// Insert sample vector.
	_, err := client.Insert(ctx, &payload.Insert_Request{
		Vector: &payload.Object_Vector{
			Id:     "id of vector",
			Vector: []float32{0.1, 0.2, 0.3}, // some feature dense vector here.
		}})
	if err != nil {
		log.Fatal(err)
	}

	// WARN you may need to wait a minutes until index creation.

	// Search sample vector.
	res, err := client.Search(ctx, &payload.Search_Request{
		Vector: vec,
		// Conditions for hitting the search.
		Config: &payload.Search_Config{
			Num:     10,        // the number of search results
			Radius:  -1,        // Radius is used to determine the space of search candidate radius for neighborhood vectors. -1 means infinite circle.
			Epsilon: 0.1,       // Epsilon is used to determines how much to expand from search candidate radius.
			Timeout: 100000000, // Timeout is used for search time deadline. The unit is nano-seconds.
		}})
	if err != nil {
		log.Fatal(err)
	}

	// Remove vector.
	_, err := client.Remove(ctx, &payload.Remove_Request{
		Id: &payload.Object_ID{
			Id: "id of vector",
		}})
	if err != nil {
		log.Fatal(err)
	}

FOSSA Status

Directories

Path Synopsis
v1
vald
Package vald provides vald server interface
Package vald provides vald server interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL