modulepackage
0.0.0-20241231190028-5ae966997032
Repository: https://github.com/aerospike/avs-client-go.git
Documentation: pkg.go.dev
# README
Aerospike Vector Search Go Client
:warning: The go client is currently in development. APIs will break in the future!
Overview
This repository contains the Go client for interacting with Aerospike Vector Search (AVS) capabilities. It is designed to provide an easy-to-use interface for performing vector searches with an Aerospike cluster.
Current Functionality
- Connection to Aerospike clusters
- Create, List, Drop Indexes
Installation
To install the Aerospike Vector Search Go Client, use the following command:
go get github.com/aerospike/avs-client-go
Example Usage
Here's a quick example to get you started:
package main
import (
"context"
"fmt"
"log/slog"
"os"
"time"
avs "github.com/aerospike/avs-client-go"
"github.com/aerospike/avs-client-go/protos"
)
func main() {
connectCtx, cancel := context.WithTimeout(context.Background(), time.Second*5)
hostPort := NewHostPort("127.0.0.1", 5000)
loadBalancer := true
credentials := NewCredentialsFromUserPass("admin", "admin")
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug}))
var (
listenerName *string
tlsConfig *tls.Config
)
client, err := avs.NewClient(
connectCtx,
HostPortSlice{hostPort},
listenerName,
loadBalancer,
credentials
tlsConfig,
logger,
)
cancel()
if err != nil {
logger.Error("failed to create admin client", slog.Any("error", err))
return
}
logger.Info("successfully connected to server")
defer client.Close()
namespace := "test"
indexName := "bookIndex"
vectorField := "vector"
dimensions := uint32(10)
distanceMetric := protos.VectorDistanceMetric_MANHATTAN
indexOpts := &IndexCreateOpts{
Set: []string{"testset"}
}
err = client.IndexCreate(
context.Background(),
namespace,
indexName,
vectorField,
dimensions,
distanceMetric,
indexOpts,
)
if err != nil {
logger.Error("failed to create index", slog.Any("error", err))
return
}
logger.Info("successfully created index")
indexes, err := client.IndexList(context.Background(), true)
if err != nil {
logger.Error("failed to list indexes", slog.Any("error", err))
return
}
for _, index := range indexes.GetIndices() {
fmt.Println(index.String())
}
err = client.IndexDrop(context.Background(), namespace, indexName)
if err != nil {
logger.Error("failed to drop index", slog.Any("error", err))
return
}
logger.Info("successfully dropped index")
logger.Info("done!")
}
License
This project is licensed under the Apache License 2.0
# Packages
No description provided by the author
# Functions
No description provided by the author
No description provided by the author
NewClient creates a new Client instance.
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
# Structs
Client is a client for managing Aerospike Vector Indexes.
No description provided by the author
No description provided by the author
IndexCreateOpts are optional fields to further configure the behavior of your index.
Neighbor represents a record that is a neighbor to a query vector.
Record represents a record in the database.
No description provided by the author
# Type aliases
No description provided by the author