Skip to content

Commit

Permalink
fix: Readme (#14)
Browse files Browse the repository at this point in the history
* fix: Readme
  • Loading branch information
Jesse S authored Oct 1, 2024
1 parent cea4c0a commit 234e991
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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))
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down

0 comments on commit 234e991

Please sign in to comment.