From 234e9913a6cc9b7f441010cb784fc700d236e97a Mon Sep 17 00:00:00 2001 From: Jesse S Date: Tue, 1 Oct 2024 15:19:41 -0700 Subject: [PATCH] fix: Readme (#14) * fix: Readme --- README.md | 40 ++++++++++++++++++++++++---------------- client.go | 1 + 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 66aabd4..b765212 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ performing vector searches with an Aerospike cluster. To install the Aerospike Vector Search Go Client, use the following command: ```bash -go get github.com/aerospike/aerospike-vector-search-go-client +go get github.com/aerospike/avs-client-go ``` ## Example Usage @@ -39,14 +39,23 @@ import ( func main() { connectCtx, cancel := context.WithTimeout(context.Background(), time.Second*5) - logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug})) 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})) - adminClient, err := avs.NewAdminClient( + var ( + listenerName *string + tlsConfig *tls.Config + ) + + client, err := avs.NewClient( connectCtx, HostPortSlice{hostPort}, - nil, - true, + listenerName, + loadBalancer, + credentials + tlsConfig, logger, ) cancel() @@ -57,26 +66,25 @@ func main() { } logger.Info("successfully connected to server") - defer adminClient.Close() + defer client.Close() namespace := "test" - set := "testset" indexName := "bookIndex" vectorField := "vector" - dimensions := 10 + dimensions := uint32(10) distanceMetric := protos.VectorDistanceMetric_MANHATTAN + indexOpts := &IndexCreateOpts{ + Set: []string{"testset"} + } - err = adminClient.IndexCreate( + err = client.IndexCreate( context.Background(), namespace, - []string{set}, indexName, vectorField, - uint32(dimensions), + dimensions, distanceMetric, - nil, - nil, - nil, + indexOpts, ) if err != nil { logger.Error("failed to create index", slog.Any("error", err)) @@ -85,7 +93,7 @@ func main() { logger.Info("successfully created index") - indexes, err := adminClient.IndexList(context.Background()) + indexes, err := client.IndexList(context.Background(), true) if err != nil { logger.Error("failed to list indexes", slog.Any("error", err)) return @@ -95,7 +103,7 @@ func main() { fmt.Println(index.String()) } - err = adminClient.IndexDrop(context.Background(), namespace, indexName) + err = client.IndexDrop(context.Background(), namespace, indexName) if err != nil { logger.Error("failed to drop index", slog.Any("error", err)) return diff --git a/client.go b/client.go index b18c6ac..7ab2af2 100644 --- a/client.go +++ b/client.go @@ -947,6 +947,7 @@ func (c *Client) IndexDrop(ctx context.Context, namespace, indexName string) err // Args: // // ctx (context.Context): The context for the operation. +// applyDefaults (bool): Whether to apply server default values to the index definitions. // // Returns: //