Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0fcb0c3
implement basic upsert functionality under the pc index upsert command
austin-denoble Nov 14, 2025
acb1b87
update off rebase, add basic index fetch command
austin-denoble Nov 16, 2025
3cd9f76
encapsulate logic for establishing and IndexConnection with a name an…
austin-denoble Nov 16, 2025
723dd6c
Implement `sdk.NewIndexConnection`, clean up `context.Context` passin…
austin-denoble Nov 17, 2025
1920cdd
implement basic upsert functionality under the pc index upsert command
austin-denoble Nov 14, 2025
a9b29ad
update off rebase, add basic index fetch command
austin-denoble Nov 16, 2025
ce67b83
encapsulate logic for establishing and IndexConnection with a name an…
austin-denoble Nov 16, 2025
023d8b5
add fetch-by-metadata functionality to the fetch command, unify prese…
austin-denoble Nov 18, 2025
d129473
add list-vectors and query commands + presentation logic
austin-denoble Nov 19, 2025
95a6164
Merge remote-tracking branch 'origin/adenoble/index-upsert-mvp' into …
austin-denoble Nov 19, 2025
a808152
remove duplicate varP flags
austin-denoble Nov 19, 2025
ebc786f
add index describe-stats command and presenter
austin-denoble Nov 19, 2025
2600550
add update-vector command to cover both by ID and metadata filter, ad…
austin-denoble Nov 19, 2025
55048ef
implement index delete-vector command
austin-denoble Nov 19, 2025
139eecd
fix describe-stats presentation output, add new commands to root inde…
austin-denoble Nov 20, 2025
db67603
add custom flags JSONObject, Float32List, and Int32List to allow easi…
austin-denoble Nov 20, 2025
d5f2b5c
improve fetch and query presentation logic
austin-denoble Nov 20, 2025
07dc1c0
default namespace properly and fix logic error
austin-denoble Nov 20, 2025
ab144f0
fix batch upsert message
austin-denoble Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/pkg/cli/command/apiKey/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func NewCreateApiKeyCmd() *cobra.Command {
pc api-key create --id "project-id" --name "key-name"
`),
Run: func(cmd *cobra.Command, args []string) {
ac := sdk.NewPineconeAdminClient()
ctx := cmd.Context()
ac := sdk.NewPineconeAdminClient(ctx)

projId := options.projectId
var err error
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/cli/command/apiKey/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func NewDeleteKeyCmd() *cobra.Command {
pc api-key delete --id "api-key-id"
`),
Run: func(cmd *cobra.Command, args []string) {
ac := sdk.NewPineconeAdminClient()
ctx := cmd.Context()
ac := sdk.NewPineconeAdminClient(ctx)

// Verify key exists before trying to delete it.
// This lets us give a more helpful error message than just
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/cli/command/apiKey/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func NewDescribeAPIKeyCmd() *cobra.Command {
`),
GroupID: help.GROUP_API_KEYS.ID,
Run: func(cmd *cobra.Command, args []string) {
ac := sdk.NewPineconeAdminClient()
ctx := cmd.Context()
ac := sdk.NewPineconeAdminClient(ctx)

apiKey, err := ac.APIKey.Describe(cmd.Context(), options.apiKeyID)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/cli/command/apiKey/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func NewListKeysCmd() *cobra.Command {
`),
GroupID: help.GROUP_API_KEYS.ID,
Run: func(cmd *cobra.Command, args []string) {
ac := sdk.NewPineconeAdminClient()
ctx := cmd.Context()
ac := sdk.NewPineconeAdminClient(ctx)

var err error
projId := options.projectID
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/cli/command/apiKey/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func NewUpdateAPIKeyCmd() *cobra.Command {
`),
GroupID: help.GROUP_API_KEYS.ID,
Run: func(cmd *cobra.Command, args []string) {
ac := sdk.NewPineconeAdminClient()
ctx := cmd.Context()
ac := sdk.NewPineconeAdminClient(ctx)

// Only set non-empty values
updateParams := &pinecone.UpdateAPIKeyParams{}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/auth/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func Run(ctx context.Context, io IO, opts configureCmdOptions) {

// Use Admin API to fetch organization and project information for the service account
// so that we can set the target context, or allow the user to set it like they do through the login or target flow
ac := sdk.NewPineconeAdminClient()
ac := sdk.NewPineconeAdminClient(ctx)

// There should only be one organization listed for a service account
orgs, err := ac.Organization.List(ctx)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/auth/local_keys_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewPruneLocalKeysCmd() *cobra.Command {
}

func runPruneLocalKeys(ctx context.Context, options pruneLocalKeysCmdOptions) {
ac := sdk.NewPineconeAdminClient()
ac := sdk.NewPineconeAdminClient(ctx)
managedKeys := secrets.GetManagedProjectKeys()

// Filter to projectId if provided
Expand Down
6 changes: 2 additions & 4 deletions internal/pkg/cli/command/collection/create.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package collection

import (
"context"

"github.com/pinecone-io/cli/internal/pkg/utils/exit"
"github.com/pinecone-io/cli/internal/pkg/utils/help"
"github.com/pinecone-io/cli/internal/pkg/utils/msg"
Expand Down Expand Up @@ -32,8 +30,8 @@ func NewCreateCollectionCmd() *cobra.Command {
pc collection create --name "collection-name" --source "index-source-name"
`),
Run: func(cmd *cobra.Command, args []string) {
pc := sdk.NewPineconeClient()
ctx := context.Background()
ctx := cmd.Context()
pc := sdk.NewPineconeClient(ctx)

req := &pinecone.CreateCollectionRequest{
Name: options.name,
Expand Down
6 changes: 2 additions & 4 deletions internal/pkg/cli/command/collection/delete.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package collection

import (
"context"

"github.com/pinecone-io/cli/internal/pkg/utils/exit"
"github.com/pinecone-io/cli/internal/pkg/utils/help"
"github.com/pinecone-io/cli/internal/pkg/utils/msg"
Expand All @@ -25,8 +23,8 @@ func NewDeleteCollectionCmd() *cobra.Command {
pc collection delete --name "collection-name"
`),
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
pc := sdk.NewPineconeClient()
ctx := cmd.Context()
pc := sdk.NewPineconeClient(ctx)

err := pc.DeleteCollection(ctx, options.name)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions internal/pkg/cli/command/collection/describe.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package collection

import (
"context"

"github.com/pinecone-io/cli/internal/pkg/utils/exit"
"github.com/pinecone-io/cli/internal/pkg/utils/help"
"github.com/pinecone-io/cli/internal/pkg/utils/msg"
Expand All @@ -28,8 +26,8 @@ func NewDescribeCollectionCmd() *cobra.Command {
pc collection describe --name "collection-name"
`),
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
pc := sdk.NewPineconeClient()
ctx := cmd.Context()
pc := sdk.NewPineconeClient(ctx)

collection, err := pc.DescribeCollection(ctx, options.name)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions internal/pkg/cli/command/collection/list.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package collection

import (
"context"
"os"
"sort"
"strconv"
Expand Down Expand Up @@ -33,8 +32,8 @@ func NewListCollectionsCmd() *cobra.Command {
pc collection list
`),
Run: func(cmd *cobra.Command, args []string) {
pc := sdk.NewPineconeClient()
ctx := context.Background()
ctx := cmd.Context()
pc := sdk.NewPineconeClient(ctx)

collections, err := pc.ListCollections(ctx)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions internal/pkg/cli/command/index/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ func NewIndexCmd() *cobra.Command {
cmd.AddCommand(NewCreatePodCmd())
cmd.AddCommand(NewConfigureIndexCmd())
cmd.AddCommand(NewDeleteCmd())
cmd.AddCommand(NewUpsertCmd())
cmd.AddCommand(NewFetchCmd())
cmd.AddCommand(NewQueryCmd())
cmd.AddCommand(NewListVectorsCmd())
cmd.AddCommand(NewDeleteVectorsCmd())
cmd.AddCommand(NewUpdateCmd())
cmd.AddCommand(NewDescribeIndexStatsCmd())

return cmd
}
7 changes: 3 additions & 4 deletions internal/pkg/cli/command/index/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewConfigureIndexCmd() *cobra.Command {
pc index configure --name "index-name" --deletion-protection "enabled"
`),
Run: func(cmd *cobra.Command, args []string) {
runConfigureIndexCmd(options)
runConfigureIndexCmd(cmd.Context(), options)
},
}

Expand All @@ -48,9 +48,8 @@ func NewConfigureIndexCmd() *cobra.Command {
return cmd
}

func runConfigureIndexCmd(options configureIndexOptions) {
ctx := context.Background()
pc := sdk.NewPineconeClient()
func runConfigureIndexCmd(ctx context.Context, options configureIndexOptions) {
pc := sdk.NewPineconeClient(ctx)

idx, err := pc.ConfigureIndex(ctx, options.name, pinecone.ConfigureIndexParams{
PodType: options.podType,
Expand Down
7 changes: 3 additions & 4 deletions internal/pkg/cli/command/index/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func NewCreateIndexCmd() *cobra.Command {
Long: createIndexHelp,
Example: createIndexExample,
Run: func(cmd *cobra.Command, args []string) {
runCreateIndexCmd(options)
runCreateIndexCmd(cmd.Context(), options)
},
}

Expand Down Expand Up @@ -141,9 +141,8 @@ func NewCreateIndexCmd() *cobra.Command {
return cmd
}

func runCreateIndexCmd(options createIndexOptions) {
ctx := context.Background()
pc := sdk.NewPineconeClient()
func runCreateIndexCmd(ctx context.Context, options createIndexOptions) {
pc := sdk.NewPineconeClient(ctx)

idx, err := runCreateIndexWithService(ctx, pc, options)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions internal/pkg/cli/command/index/create_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewCreatePodCmd() *cobra.Command {
pc index create-pod --name "my-index" --dimension 1536 --metric "cosine" --environment "us-east-1-aws" --pod-type "p1.x1" --shards 2 --replicas 2
`),
Run: func(cmd *cobra.Command, args []string) {
runCreatePodCmd(options)
runCreatePodCmd(cmd.Context(), options)
},
}

Expand All @@ -65,9 +65,8 @@ func NewCreatePodCmd() *cobra.Command {
return cmd
}

func runCreatePodCmd(options createPodOptions) {
ctx := context.Background()
pc := sdk.NewPineconeClient()
func runCreatePodCmd(ctx context.Context, options createPodOptions) {
pc := sdk.NewPineconeClient(ctx)

// Deprecation warning
pcio.Fprintf(os.Stderr, "⚠️ Warning: The '%s' command is deprecated. Please use '%s' instead.", style.Code("index create-pod"), style.Code("index create"))
Expand Down
7 changes: 3 additions & 4 deletions internal/pkg/cli/command/index/create_serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewCreateServerlessCmd() *cobra.Command {
pc index create-serverless --name "my-index" --dimension 1536 --metric "cosine" --cloud "aws" --region "us-east-1"
`),
Run: func(cmd *cobra.Command, args []string) {
runCreateServerlessCmd(options)
runCreateServerlessCmd(cmd.Context(), options)
},
}

Expand All @@ -58,9 +58,8 @@ func NewCreateServerlessCmd() *cobra.Command {
return cmd
}

func runCreateServerlessCmd(options createServerlessOptions) {
ctx := context.Background()
pc := sdk.NewPineconeClient()
func runCreateServerlessCmd(ctx context.Context, options createServerlessOptions) {
pc := sdk.NewPineconeClient(ctx)

// Deprecation warning
pcio.Fprintf(os.Stderr, "⚠️ Warning: The '%s' command is deprecated. Please use '%s' instead.", style.Code("index create-serverless"), style.Code("index create"))
Expand Down
5 changes: 2 additions & 3 deletions internal/pkg/cli/command/index/delete.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package index

import (
"context"
"strings"

"github.com/pinecone-io/cli/internal/pkg/utils/exit"
Expand All @@ -26,8 +25,8 @@ func NewDeleteCmd() *cobra.Command {
pc index delete --name "index-name"
`),
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
pc := sdk.NewPineconeClient()
ctx := cmd.Context()
pc := sdk.NewPineconeClient(ctx)

err := pc.DeleteIndex(ctx, options.name)
if err != nil {
Expand Down
111 changes: 111 additions & 0 deletions internal/pkg/cli/command/index/delete_vectors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package index

import (
"context"

"github.com/pinecone-io/cli/internal/pkg/utils/exit"
"github.com/pinecone-io/cli/internal/pkg/utils/flags"
"github.com/pinecone-io/cli/internal/pkg/utils/help"
"github.com/pinecone-io/cli/internal/pkg/utils/msg"
"github.com/pinecone-io/cli/internal/pkg/utils/sdk"
"github.com/pinecone-io/go-pinecone/v5/pinecone"
"github.com/spf13/cobra"
)

type deleteVectorsCmdOptions struct {
name string
namespace string
ids []string
filter flags.JSONObject
deleteAll bool
json bool
}

func NewDeleteVectorsCmd() *cobra.Command {
options := deleteVectorsCmdOptions{}

cmd := &cobra.Command{
Use: "delete-vectors",
Short: "Delete vectors from an index",
Example: help.Examples(`
pc index delete-vectors --name my-index --namespace my-namespace --ids my-id
pc index delete-vectors --namespace my-namespace --all-vectors
pc index delete-vectors --namespace my-namespace --filter '{"genre": "classical"}'
`),
Run: func(cmd *cobra.Command, args []string) {
runDeleteVectorsCmd(cmd.Context(), options)
},
}

cmd.Flags().StringVarP(&options.name, "name", "n", "", "name of the index to delete vectors from")
cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to delete vectors from")
cmd.Flags().StringSliceVar(&options.ids, "ids", []string{}, "IDs of the vectors to delete")
cmd.Flags().Var(&options.filter, "filter", "filter to delete the vectors with")
cmd.Flags().BoolVar(&options.deleteAll, "all-vectors", false, "delete all vectors from the namespace")
cmd.Flags().BoolVar(&options.json, "json", false, "output as JSON")

_ = cmd.MarkFlagRequired("name")

return cmd
}

func runDeleteVectorsCmd(ctx context.Context, options deleteVectorsCmdOptions) {
pc := sdk.NewPineconeClient(ctx)

// Default namespace
ns := options.namespace
if ns == "" {
ns = "__default__"
}

ic, err := sdk.NewIndexConnection(ctx, pc, options.name, ns)
if err != nil {
msg.FailMsg("Failed to create index connection: %s", err)
exit.Error(err, "Failed to create index connection")
}

// Delete all vectors in namespace
if options.deleteAll {
err = ic.DeleteAllVectorsInNamespace(ctx)
if err != nil {
msg.FailMsg("Failed to delete all vectors in namespace: %s", err)
exit.Error(err, "Failed to delete all vectors in namespace")
}
if !options.json {
msg.SuccessMsg("Deleted all vectors in namespace: %s", ns)
}
return
}

// Delete vectors by ID
if len(options.ids) > 0 {
err = ic.DeleteVectorsById(ctx, options.ids)
if err != nil {
msg.FailMsg("Failed to delete vectors by IDs: %s", err)
exit.Error(err, "Failed to delete vectors by IDs")
}
if !options.json {
msg.SuccessMsg("Deleted vectors by IDs: %s", options.ids)
}
return
}

// Delete vectors by filter
if options.filter != nil {
filter, err := pinecone.NewMetadataFilter(options.filter)
if err != nil {
msg.FailMsg("Failed to create filter: %s", err)
exit.Errorf(err, "Failed to create filter")
}

err = ic.DeleteVectorsByFilter(ctx, filter)
if err != nil {
msg.FailMsg("Failed to delete vectors by filter: %s", err)
exit.Error(err, "Failed to delete vectors by filter")
}
if !options.json {
msg.SuccessMsg("Deleted vectors by filter: %s", filter.String())
}
return
}
}
3 changes: 2 additions & 1 deletion internal/pkg/cli/command/index/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func NewDescribeCmd() *cobra.Command {
pc index describe --name "index-name"
`),
Run: func(cmd *cobra.Command, args []string) {
pc := sdk.NewPineconeClient()
ctx := cmd.Context()
pc := sdk.NewPineconeClient(ctx)

idx, err := pc.DescribeIndex(cmd.Context(), options.name)
if err != nil {
Expand Down
Loading
Loading