diff --git a/internal/pkg/cli/command/index/record/search.go b/internal/pkg/cli/command/index/record/search.go index 8ceaf7d..3da6344 100644 --- a/internal/pkg/cli/command/index/record/search.go +++ b/internal/pkg/cli/command/index/record/search.go @@ -111,7 +111,7 @@ func NewSearchCmd() *cobra.Command { } cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to search") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to search") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "namespace to search") cmd.Flags().IntVarP(&options.topK, "top-k", "k", defaultSearchTopK, "number of results to return") cmd.Flags().Var(&options.inputs, "inputs", "query inputs for search (inline JSON, ./path.json, or '-' for stdin); requires integrated embedding") cmd.Flags().Var(&options.filter, "filter", "metadata filter (inline JSON, ./path.json, or '-' for stdin)") diff --git a/internal/pkg/cli/command/index/record/upsert.go b/internal/pkg/cli/command/index/record/upsert.go index 5fb9813..0225320 100644 --- a/internal/pkg/cli/command/index/record/upsert.go +++ b/internal/pkg/cli/command/index/record/upsert.go @@ -75,7 +75,7 @@ func NewUpsertCmd() *cobra.Command { } cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of index to upsert into") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to upsert into") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "namespace to upsert into") cmd.Flags().StringVar(&options.file, "file", "", "request body JSON or JSONL (inline, ./path.json[l], or '-' for stdin; only one argument may use stdin)") cmd.Flags().StringVar(&options.file, "body", "", "alias for --file") cmd.Flags().IntVarP(&options.batchSize, "batch-size", "b", 96, "records per batch (max 96)") diff --git a/internal/pkg/cli/command/index/vector/delete.go b/internal/pkg/cli/command/index/vector/delete.go index bea3cc6..2c8a787 100644 --- a/internal/pkg/cli/command/index/vector/delete.go +++ b/internal/pkg/cli/command/index/vector/delete.go @@ -44,7 +44,7 @@ func NewDeleteVectorsCmd() *cobra.Command { } cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to delete vectors from") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to delete vectors from") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "namespace to delete vectors from") cmd.Flags().Var(&options.ids, "ids", "IDs of the vectors to delete (inline JSON string array, ./path.json, or '-' for stdin)") cmd.Flags().Var(&options.filter, "filter", "filter to delete the vectors with (inline JSON, ./path.json, or '-' for stdin)") cmd.Flags().BoolVar(&options.deleteAllVectors, "all-vectors", false, "delete all vectors from the namespace") diff --git a/internal/pkg/cli/command/index/vector/fetch.go b/internal/pkg/cli/command/index/vector/fetch.go index 48fc76e..5a92c63 100644 --- a/internal/pkg/cli/command/index/vector/fetch.go +++ b/internal/pkg/cli/command/index/vector/fetch.go @@ -69,7 +69,7 @@ func NewFetchCmd() *cobra.Command { cmd.Flags().VarP(&options.ids, "ids", "i", "IDs of vectors to fetch (inline JSON string array, ./path.json, or '-' for stdin)") cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the fetch (inline JSON, ./path.json, or '-' for stdin)") cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to fetch from") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to fetch from") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "namespace to fetch from") cmd.Flags().Uint32VarP(&options.limit, "limit", "l", 0, "maximum number of vectors to fetch") cmd.Flags().StringVarP(&options.paginationToken, "pagination-token", "p", "", "pagination token to continue a previous listing operation") cmd.Flags().StringVar(&options.body, "body", "", "request body JSON (inline, ./path.json, or '-' for stdin; only one argument may use stdin)") diff --git a/internal/pkg/cli/command/index/vector/list_vectors.go b/internal/pkg/cli/command/index/vector/list_vectors.go index 0bae7cb..489b6d0 100644 --- a/internal/pkg/cli/command/index/vector/list_vectors.go +++ b/internal/pkg/cli/command/index/vector/list_vectors.go @@ -37,7 +37,7 @@ func NewListVectorsCmd() *cobra.Command { } cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to list vectors from") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to list vectors from") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "namespace to list vectors from") cmd.Flags().Uint32VarP(&options.limit, "limit", "l", 0, "maximum number of vectors to list") cmd.Flags().StringVarP(&options.paginationToken, "pagination-token", "p", "", "pagination token to continue a previous listing operation") cmd.Flags().BoolVarP(&options.json, "json", "j", false, "output as JSON") diff --git a/internal/pkg/cli/command/index/vector/query.go b/internal/pkg/cli/command/index/vector/query.go index a3871c8..0141c2f 100644 --- a/internal/pkg/cli/command/index/vector/query.go +++ b/internal/pkg/cli/command/index/vector/query.go @@ -82,7 +82,7 @@ func NewQueryCmd() *cobra.Command { } cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to query") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "index namespace to query") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "index namespace to query") cmd.Flags().Uint32VarP(&options.topK, "top-k", "k", 10, "maximum number of results to return") cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the query (inline JSON, ./path.json, or '-' for stdin)") cmd.Flags().BoolVar(&options.includeValues, "include-values", false, "include vector values in the query results") diff --git a/internal/pkg/cli/command/index/vector/update.go b/internal/pkg/cli/command/index/vector/update.go index 6a3664b..e8da238 100644 --- a/internal/pkg/cli/command/index/vector/update.go +++ b/internal/pkg/cli/command/index/vector/update.go @@ -71,7 +71,7 @@ func NewUpdateCmd() *cobra.Command { } cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to update") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to update the vector in") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "namespace to update the vector in") cmd.Flags().StringVar(&options.id, "id", "", "ID of the vector to update") cmd.Flags().Var(&options.values, "values", "values to update the vector with (inline JSON array, ./path.json, or '-' for stdin)") cmd.Flags().Var(&options.sparseIndices, "sparse-indices", "sparse indices to update the vector with (inline JSON array, ./path.json, or '-' for stdin)") diff --git a/internal/pkg/cli/command/index/vector/upsert.go b/internal/pkg/cli/command/index/vector/upsert.go index 3408e54..b7b9b28 100644 --- a/internal/pkg/cli/command/index/vector/upsert.go +++ b/internal/pkg/cli/command/index/vector/upsert.go @@ -61,7 +61,7 @@ func NewUpsertCmd() *cobra.Command { } cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of index to upsert into") - cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to upsert into") + cmd.Flags().StringVar(&options.namespace, "namespace", "", "namespace to upsert into") cmd.Flags().StringVar(&options.file, "file", "", "request body JSON or JSONL (inline, ./path.json[l], or '-' for stdin; only one argument may use stdin)") cmd.Flags().StringVar(&options.file, "body", "", "alias for --file") cmd.Flags().IntVarP(&options.batchSize, "batch-size", "b", 500, "size of batches to upsert (default: 500)") diff --git a/internal/pkg/utils/sdk/client.go b/internal/pkg/utils/sdk/client.go index ae9f140..1fccd92 100644 --- a/internal/pkg/utils/sdk/client.go +++ b/internal/pkg/utils/sdk/client.go @@ -170,7 +170,11 @@ func NewIndexConnection(ctx context.Context, pc *pinecone.Client, indexName stri if err != nil { return nil, fmt.Errorf("failed to create index connection: %w", err) } - return ic, nil + // The SDK coerces Namespace="" to "__default__" inside pc.Index. Re-apply + // the caller's value via WithNamespace so that an empty namespace is sent + // as "" on the wire (proto3 zero value) rather than the literal string + // "__default__", which requires an active server-side conversion. + return ic.WithNamespace(namespace), nil } func getCLIAPIKeyForProject(ctx context.Context, ac *pinecone.AdminClient, project *pinecone.Project) (string, error) {