Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sparse index support #95

Merged
merged 9 commits into from
Feb 4, 2025
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func main() {

**Create a serverless index**

The following example creates a serverless index in the `us-east-1`
The following example creates a `dense` serverless index in the `us-east-1`
region of AWS. For more information on serverless and regional availability,
see [Understanding indexes](https://docs.pinecone.io/guides/indexes/understanding-indexes#serverless-indexes).

Expand Down Expand Up @@ -167,6 +167,53 @@ func main() {
}
```

You can also create `sparse` only serverless indexes. These indexes enable direct indexing and retrieval of sparse vectors, supporting traditional methods like BM25 and learned sparse models such as [pinecone-sparse-english-v0](https://docs.pinecone.io/models/pinecone-sparse-english-v0). A `sparse` index must have a distance metric of `dotproduct` and does not require a specified dimension:

```go
package main

import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)

func main() {
ctx := context.Background()

clientParams := pinecone.NewClientParams{
ApiKey: os.Getenv("PINECONE_API_KEY"),
}

pc, err := pinecone.NewClient(clientParams)
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
} else {
fmt.Println("Successfully created a new Client object!")
}

indexName := "my-serverless-index"
vectorType := "dense"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to show an example for vectorType = sparse?


idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{
Name: indexName,
Metric: pinecone.Dotproduct,
VectorType: &vectorType,
Cloud: pinecone.Aws,
Region: "us-east-1",
Tags: &pinecone.IndexTags{"environment": "development"},
})

if err != nil {
log.Fatalf("Failed to create serverless index: %v", err)
} else {
fmt.Printf("Successfully created serverless index: %s", idx.Name)
}
}
```

**Create a pod-based index**

The following example creates a pod-based index with a metadata configuration. If no metadata configuration is
Expand Down
2 changes: 1 addition & 1 deletion codegen/apis
Submodule apis updated from 8fdecc to 63e97d
36 changes: 18 additions & 18 deletions internal/gen/db_data/grpc/db_data_2025-01_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions internal/gen/db_data/rest/db_data_2025-01.oas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion internal/gen/inference/inference_2025-01.oas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading