Release v5.2.0
v5.2.0 resolves problems when using Client.ConfigureIndex to adjust an index's dedicated read node configuration via ReadCapacityParams. Previously, all fields were required in ReadCapacityDedicatedConfig and ReadCapacityScaling, which meant if you were trying to configure a dedicated index to update individual NodeType, Shards, or Replicas, the JSON marshaled would contain zero-values. These fields have been updated to pointers to represent optionality across usage in Client.CreateIndex, and Client.ConfigureIndex. These fields are now represented as pointers in the ReadCapacity responses for index models elsewhere.
Additionally, ReadCapacityParams also includes an explicit OnDemand field, and ReadCapacityOnDemandConfig has been added. These enable converting from an existing dedicated index to on demand. The following example creates an on demand index, converts to dedicated, and then adjusts the dedicated configuration.
import (
"context"
"fmt"
"log"
"github.com/pinecone-io/go-pinecone/v5/pinecone"
)
func ConfigureDedicatedReadNodes() {
ctx := context.Background()
pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: "YOUR_API_KEY",
})
if err != nil {
log.Fatalf("Failed to create Client: %v", err)
}
// Create the serverless index with on demand read capacity (default)
dimension := int32(1024)
metric := pinecone.Cosine
idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{
Name: "my-serverless-index",
Dimension: &dimension,
Metric: &metric,
Cloud: pinecone.Aws,
Region: "us-east-1",
})
if err != nil {
log.Fatalf("Failed to create serverless index: %v", err)
}
fmt.Printf("Successfully created index: %s\n", idx.Name)
// Convert the index to dedicated
nodeType := "t1"
shards := int32(1)
replicas := int32(1)
updatedIdx, err := pc.ConfigureIndex(ctx, "my-serverless-index", pinecone.ConfigureIndexParams{
ReadCapacity: &pinecone.ReadCapacityParams{
Dedicated: &pinecone.ReadCapacityDedicatedConfig{
NodeType: &nodeType,
Scaling: &pinecone.ReadCapacityScaling{
Manual: &pinecone.ReadCapacityManualScaling{
Replicas: &replicas,
Shards: &shards,
},
},
},
},
})
if err != nil {
log.Fatalf("Failed to configure index: %v", err)
}
fmt.Printf("Successfully updated index %s read capacity. Status: %+v\n", "my-serverless-index",
updatedIdx.Spec.Serverless.ReadCapacity.Dedicated)
// Update dedicated index read capacity configuration
newShards := int32(2)
newReplicas := int32(2)
updatedIdx, err = pc.ConfigureIndex(ctx, "my-serverless-index", pinecone.ConfigureIndexParams{
ReadCapacity: &pinecone.ReadCapacityParams{
Dedicated: &pinecone.ReadCapacityDedicatedConfig{
Scaling: &pinecone.ReadCapacityScaling{
Manual: &pinecone.ReadCapacityManualScaling{
Replicas: &newReplicas,
Shards: &newShards,
},
},
},
},
})
if err != nil {
log.Fatalf("Failed to configure index: %v", err)
}
fmt.Printf("Successfully updated index %s read capacity. Status: %+v\n", "my-serverless-index",
updatedIdx.Spec.Serverless.ReadCapacity.Dedicated)
}