Documentation
¶
Overview ¶
Package pinecone provides a client for the Pinecone managed vector database.
Index ¶
- type APIKey
- type APIKeyClient
- type APIKeyWithSecret
- type AdminClient
- type Backup
- type BackupList
- type Client
- func (c *Client) ConfigureIndex(ctx context.Context, name string, in ConfigureIndexParams) (*Index, error)
- func (c *Client) CreateBackup(ctx context.Context, in *CreateBackupParams) (*Backup, error)
- func (c *Client) CreateCollection(ctx context.Context, in *CreateCollectionRequest) (*Collection, error)
- func (c *Client) CreateIndexForModel(ctx context.Context, in *CreateIndexForModelRequest) (*Index, error)
- func (c *Client) CreateIndexFromBackup(ctx context.Context, in *CreateIndexFromBackupParams) (*CreateIndexFromBackupResponse, error)
- func (c *Client) CreatePodIndex(ctx context.Context, in *CreatePodIndexRequest) (*Index, error)
- func (c *Client) CreateServerlessIndex(ctx context.Context, in *CreateServerlessIndexRequest) (*Index, error)
- func (c *Client) DeleteBackup(ctx context.Context, backupId string) error
- func (c *Client) DeleteCollection(ctx context.Context, collectionName string) error
- func (c *Client) DeleteIndex(ctx context.Context, idxName string) error
- func (c *Client) DescribeBackup(ctx context.Context, backupId string) (*Backup, error)
- func (c *Client) DescribeCollection(ctx context.Context, collectionName string) (*Collection, error)
- func (c *Client) DescribeIndex(ctx context.Context, idxName string) (*Index, error)
- func (c *Client) DescribeRestoreJob(ctx context.Context, restoreJobId string) (*RestoreJob, error)
- func (c *Client) Index(in NewIndexConnParams, dialOpts ...grpc.DialOption) (*IndexConnection, error)
- func (c *Client) ListBackups(ctx context.Context, in *ListBackupsParams) (*BackupList, error)
- func (c *Client) ListCollections(ctx context.Context) ([]*Collection, error)
- func (c *Client) ListIndexes(ctx context.Context) ([]*Index, error)
- func (c *Client) ListRestoreJobs(ctx context.Context, in *ListRestoreJobsParams) (*RestoreJobList, error)
- type Cloud
- type Collection
- type CollectionStatus
- type ConfigureIndexEmbed
- type ConfigureIndexParams
- type CreateAPIKeyParams
- type CreateBackupParams
- type CreateCollectionRequest
- type CreateIndexForModelEmbed
- type CreateIndexForModelRequest
- type CreateIndexFromBackupParams
- type CreateIndexFromBackupResponse
- type CreatePodIndexRequest
- type CreateProjectParams
- type CreateServerlessIndexRequest
- type DefaultApiKeyClient
- func (a *DefaultApiKeyClient) Create(ctx context.Context, projectId string, in *CreateAPIKeyParams) (*APIKeyWithSecret, error)
- func (a *DefaultApiKeyClient) Delete(ctx context.Context, apiKeyId string) error
- func (a *DefaultApiKeyClient) Describe(ctx context.Context, apiKeyId string) (*APIKey, error)
- func (a *DefaultApiKeyClient) List(ctx context.Context, projectId string) ([]*APIKey, error)
- func (a *DefaultApiKeyClient) Update(ctx context.Context, apiKeyId string, in *UpdateAPIKeyParams) (*APIKey, error)
- type DefaultOrganizationClient
- func (o *DefaultOrganizationClient) Delete(ctx context.Context, organizationId string) error
- func (o *DefaultOrganizationClient) Describe(ctx context.Context, organizationId string) (*Organization, error)
- func (o *DefaultOrganizationClient) List(ctx context.Context) ([]*Organization, error)
- func (o *DefaultOrganizationClient) Update(ctx context.Context, organizationId string, in *UpdateOrganizationParams) (*Organization, error)
- type DefaultProjectClient
- func (p *DefaultProjectClient) Create(ctx context.Context, in *CreateProjectParams) (*Project, error)
- func (p *DefaultProjectClient) Delete(ctx context.Context, projectId string) error
- func (p *DefaultProjectClient) Describe(ctx context.Context, projectId string) (*Project, error)
- func (p *DefaultProjectClient) List(ctx context.Context) ([]*Project, error)
- func (p *DefaultProjectClient) Update(ctx context.Context, projectId string, in *UpdateProjectParams) (*Project, error)
- type DeletionProtection
- type DenseEmbedding
- type DescribeIndexStatsResponse
- type Document
- type EmbedParameters
- type EmbedRequest
- type EmbedResponse
- type Embedding
- type FetchVectorsResponse
- type Hit
- type Import
- type ImportErrorMode
- type ImportStatus
- type Index
- type IndexConnection
- func (idx *IndexConnection) CancelImport(ctx context.Context, id string) error
- func (idx *IndexConnection) Close() error
- func (idx *IndexConnection) DeleteAllVectorsInNamespace(ctx context.Context) error
- func (idx *IndexConnection) DeleteNamespace(ctx context.Context, namespace string) error
- func (idx *IndexConnection) DeleteVectorsByFilter(ctx context.Context, metadataFilter *MetadataFilter) error
- func (idx *IndexConnection) DeleteVectorsById(ctx context.Context, ids []string) error
- func (idx *IndexConnection) DescribeImport(ctx context.Context, id string) (*Import, error)
- func (idx *IndexConnection) DescribeIndexStats(ctx context.Context) (*DescribeIndexStatsResponse, error)
- func (idx *IndexConnection) DescribeIndexStatsFiltered(ctx context.Context, metadataFilter *MetadataFilter) (*DescribeIndexStatsResponse, error)
- func (idx *IndexConnection) DescribeNamespace(ctx context.Context, namespace string) (*NamespaceDescription, error)
- func (idx *IndexConnection) FetchVectors(ctx context.Context, ids []string) (*FetchVectorsResponse, error)
- func (idx *IndexConnection) ListImports(ctx context.Context, limit *int32, paginationToken *string) (*ListImportsResponse, error)
- func (idx *IndexConnection) ListNamespaces(ctx context.Context, in *ListNamespacesParams) (*ListNamespacesResponse, error)
- func (idx *IndexConnection) ListVectors(ctx context.Context, in *ListVectorsRequest) (*ListVectorsResponse, error)
- func (idx *IndexConnection) Namespace() string
- func (idx *IndexConnection) QueryByVectorId(ctx context.Context, in *QueryByVectorIdRequest) (*QueryVectorsResponse, error)
- func (idx *IndexConnection) QueryByVectorValues(ctx context.Context, in *QueryByVectorValuesRequest) (*QueryVectorsResponse, error)
- func (idx *IndexConnection) SearchRecords(ctx context.Context, in *SearchRecordsRequest) (*SearchRecordsResponse, error)
- func (idx *IndexConnection) StartImport(ctx context.Context, uri string, integrationId *string, ...) (*StartImportResponse, error)
- func (idx *IndexConnection) UpdateVector(ctx context.Context, in *UpdateVectorRequest) error
- func (idx *IndexConnection) UpsertRecords(ctx context.Context, records []*IntegratedRecord) error
- func (idx *IndexConnection) UpsertVectors(ctx context.Context, in []*Vector) (uint32, error)
- func (idx *IndexConnection) WithNamespace(namespace string) *IndexConnection
- type IndexEmbed
- type IndexMetric
- type IndexSpec
- type IndexStatus
- type IndexStatusState
- type IndexTags
- type InferenceService
- func (i *InferenceService) DescribeModel(ctx context.Context, modelName string) (*ModelInfo, error)
- func (i *InferenceService) Embed(ctx context.Context, in *EmbedRequest) (*EmbedResponse, error)
- func (i *InferenceService) ListModels(ctx context.Context, in *ListModelsParams) (*ModelInfoList, error)
- func (i *InferenceService) Rerank(ctx context.Context, in *RerankRequest) (*RerankResponse, error)
- type IntegratedRecord
- type ListBackupsParams
- type ListImportsRequest
- type ListImportsResponse
- type ListModelsParams
- type ListNamespacesParams
- type ListNamespacesResponse
- type ListRestoreJobsParams
- type ListVectorsRequest
- type ListVectorsResponse
- type Metadata
- type MetadataFilter
- type ModelInfo
- type ModelInfoList
- type NamespaceDescription
- type NamespaceSummary
- type NewAdminClientParams
- type NewClientBaseParams
- type NewClientParams
- type NewIndexConnParams
- type Organization
- type OrganizationClient
- type Pagination
- type PineconeError
- type PodSpec
- type PodSpecMetadataConfig
- type Project
- type ProjectClient
- type QueryByVectorIdRequest
- type QueryByVectorValuesRequest
- type QueryVectorsResponse
- type RankedDocument
- type RerankRequest
- type RerankResponse
- type RerankUsage
- type RestoreJob
- type RestoreJobList
- type ScoredVector
- type SearchRecordsQuery
- type SearchRecordsRequest
- type SearchRecordsRerank
- type SearchRecordsResponse
- type SearchRecordsVector
- type SearchUsage
- type ServerlessSpec
- type SparseEmbedding
- type SparseValues
- type StartImportResponse
- type SupportedParameter
- type SupportedParameterValue
- type UpdateAPIKeyParams
- type UpdateOrganizationParams
- type UpdateProjectParams
- type UpdateVectorRequest
- type Usage
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶ added in v4.1.0
type APIKey struct { // The name of the API key. Name string `json:"name"` // The unique ID of the API key. Id string `json:"id"` // The ID of the project containing the API key. ProjectId string `json:"project_id"` // The roles assigned to the API key. Roles []string `json:"roles"` }
APIKey represents the details of an API key without the secret.
type APIKeyClient ¶ added in v4.1.0
type APIKeyClient interface { // Create a new API key. Create(ctx context.Context, projectId string, in *CreateAPIKeyParams) (*APIKeyWithSecret, error) // Update an existing API key by ID. Update(ctx context.Context, apiKeyId string, in *UpdateAPIKeyParams) (*APIKey, error) // List all API keys within a project by project ID. List(ctx context.Context, projectId string) ([]*APIKey, error) // Describe an API key by ID. Describe(ctx context.Context, apiKeyId string) (*APIKey, error) // Delete an API key by ID. Delete(ctx context.Context, apiKeyId string) error }
APIKeyClient provides an interface for managing API keys within a project.
type APIKeyWithSecret ¶ added in v4.1.0
type APIKeyWithSecret struct { // The details of an [APIKey], without the secret. Key APIKey `json:"key"` // The value to use as an API key. New keys will have the format `"pckey_<public-label>_<unique-key>"`. // The entire string should be used when authenticating. Value string `json:"value"` }
APIKeyWithSecret represents the details of an API key with the secret.
type AdminClient ¶ added in v4.1.0
type AdminClient struct { // Project provides methods for creating, updating, listing, describing, // and deleting projects. Project ProjectClient // Organization provides methods for listing, describing, updating, // and deleting organizations. Organization OrganizationClient // APIKey provides methods for creating, updating, listing, describing, // and deleting API keys within a project. APIKey APIKeyClient }
AdminClient provides access to Pinecone's administrative APIs, which supports managing projects, organizations, and API keys. It is constructed using NewAdminClient or NewAdminClientWithContext.
func NewAdminClient ¶ added in v4.1.0
func NewAdminClient(in NewAdminClientParams) (*AdminClient, error)
NewAdminClient returns a new AdminClient using the given parameters, using context.Background as the default context. It validates the client ID and secret from the input or environment, authenticates, and constructs an authorized AdminClient.
func NewAdminClientWithContext ¶ added in v4.1.0
func NewAdminClientWithContext(ctx context.Context, in NewAdminClientParams) (*AdminClient, error)
NewAdminClientWithContext returns a new AdminClient using the provided context and parameters. This function allows for finer control over timeout, and cancellation of the authentication request. It validates the client ID and secret from the input or environment, authenticates, and constructs an authorized AdminClient.
type Backup ¶
type Backup struct { BackupId string `json:"backup_id"` Cloud string `json:"cloud"` CreatedAt *string `json:"created_at,omitempty"` Description *string `json:"description,omitempty"` Dimension *int32 `json:"dimension,omitempty"` Metric *IndexMetric `json:"metric,omitempty"` Name *string `json:"name,omitempty"` NamespaceCount *int `json:"namespace_count,omitempty"` RecordCount *int `json:"record_count,omitempty"` Region string `json:"region"` SizeBytes *int `json:"size_bytes,omitempty"` SourceIndexId string `json:"source_index_id"` SourceIndexName string `json:"source_index_name"` Status string `json:"status"` Tags *IndexTags `json:"tags,omitempty"` }
Backup describes the configuration and status of a Pinecone backup.
Fields:
- BackupId: Unique identifier for the backup.
- Cloud: Cloud provider where the backup is stored.
- CreatedAt: Timestamp when the backup was created.
- Description: Optional description providing context for the backup.
- Dimension: The dimensions of the vectors to be inserted in the index.
- Metric: The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. If the 'vector_type' is 'sparse', the metric must be 'dotproduct'. If the `vector_type` is `dense`, the metric defaults to 'cosine'.
- Name: Optional user-defined name for the backup.
- NamespaceCount: Number of namespaces in the backup.
- RecordCount: Total number of records in the backup.
- Region: Cloud region where the backup is stored.
- SizeBytes: Size of the backup in bytes.
- SourceIndexId: ID of the index.
- SourceIndexName: Name of the index from which the backup was taken.
- Status: Current status of the backup (e.g., Initializing, Ready, Failed).
- Tags: Custom user tags added to an index. Keys must be 80 characters or less. Values must be 120 characters or less. Keys must be alphanumeric, '_', or '-'. Values must be alphanumeric, ';', '@', '_', '-', '.', '+', or ' '. To unset a key, set the value to an empty string.
type BackupList ¶
type BackupList struct { Data []*Backup `json:"data"` Pagination *Pagination `json:"pagination,omitempty"` }
BackupList contains a paginated list of backups.
Fields:
- Data: A list of Backup records.
- Pagination: Pagination token for fetching the next page of results.
type Client ¶
type Client struct { Inference *InferenceService // contains filtered or unexported fields }
Client holds the parameters for connecting to the Pinecone service. It is returned by the NewClient and NewClientBase functions. To use Client, first build the parameters of the request using NewClientParams (or NewClientBaseParams). Then, pass those parameters into the NewClient (or NewClientBase) function to create a new Client object. Once instantiated, you can use Client to execute Pinecone API requests (e.g. create an Index, list Indexes, etc.), and Inference API requests. Read more about different Pinecone API routes here.
Note: Client methods are safe for concurrent use.
Fields:
- Inference: An InferenceService object that exposes methods for interacting with the Pinecone Inference API.
- restClient: Optional underlying *http.Client object used to communicate with the Pinecone API, provided through [NewClientParams.RestClient] or [NewClientBaseParams.RestClient]. If not provided, a default client is created for you.
- baseParams: A NewClientBaseParams object that holds the configuration for the Pinecone client.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) // --> This creates a new Client object. if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } else { fmt.Printf("Successfully found the \"%s\" index!\n", idx.Name) } idxConnection, err := pc.Index(idx.Host) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } else { log.Println("IndexConnection created successfully!") }
func NewClient ¶
func NewClient(in NewClientParams) (*Client, error)
NewClient creates and initializes a new instance of Client. This function sets up the Pinecone client with the necessary configuration for authentication and communication.
Parameters:
- in: A NewClientParams object. See NewClientParams for more information.
Note: It is important to handle the error returned by this function to ensure that the Pinecone client has been created successfully before attempting to make API calls.
Returns a pointer to an initialized Client instance or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") }
func NewClientBase ¶
func NewClientBase(in NewClientBaseParams) (*Client, error)
NewClientBase creates and initializes a new instance of Client with custom authentication headers.
Parameters:
- in: A NewClientBaseParams object that includes the necessary configuration for the Pinecone client. See NewClientBaseParams for more information.
Notes:
- It is important to handle the error returned by this function to ensure that the Pinecone client has been created successfully before attempting to make API calls.
- A Pinecone API key is not required when using NewClientBase.
Returns a pointer to an initialized Client instance or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientBaseParams{ Headers: map[string]string{ "Authorization": "Bearer " + "<your OAuth token>" "X-Project-Id": "<Your Pinecone project ID>" }, SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClientBase(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } else { fmt.Println("Successfully created a new Client object!") }
func (*Client) ConfigureIndex ¶
func (c *Client) ConfigureIndex(ctx context.Context, name string, in ConfigureIndexParams) (*Index, error)
Client.ConfigureIndex is used to scale a pods-based index up or down by changing the size of the pods or the number of replicas, or to enable and disable deletion protection for an Index.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- name: The name of the Index to configure.
- in: A pointer to a ConfigureIndexParams object that contains the parameters for configuring the Index.
Note: You can only scale an Index up, not down. If you want to scale an Index down, you must create a new index with the desired configuration.
Returns a pointer to a configured Index object or an error.
Example:
// To scale the size of your pods-based index from "x2" to "x4": _, err := pc.ConfigureIndex(ctx, "my-pod-index", ConfigureIndexParams{PodType: "p1.x4"}) if err != nil { fmt.Printf("Failed to configure index: %v\n", err) } // To scale the number of replicas: _, err := pc.ConfigureIndex(ctx, "my-pod-index", ConfigureIndexParams{Replicas: 4}) if err != nil { fmt.Printf("Failed to configure index: %v\n", err) } // To scale both the size of your pods and the number of replicas to 4: _, err := pc.ConfigureIndex(ctx, "my-pod-index", ConfigureIndexParams{PodType: "p1.x4", Replicas: 4}) if err != nil { fmt.Printf("Failed to configure index: %v\n", err) } // To enable deletion protection: _, err := pc.ConfigureIndex(ctx, "my-index", ConfigureIndexParams{DeletionProtection: "enabled"}) if err != nil { fmt.Printf("Failed to configure index: %v\n", err) }
func (*Client) CreateBackup ¶
Client.CreateBackup creates a Backup for an index.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a CreateBackupParams object.
Note: Backups are only available for serverless Indexes.
Returns a pointer to a Backup object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_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!") } index, err := pc.DescribeIndex(ctx, "my-index") if err != nil { log.Fatalf("Failed to describe index: %v", err) } backupDesc := fmt.Sprintf("%s-backup", index.Name) backupName := "my-backup" backup, err := pc.CreateBackup(ctx, &pinecone.CreateBackupParams{ IndexName: index.Name, Name: &backupName, Description: &backupDesc, }) if err != nil { log.Fatalf("Failed to create collection: %v", err) } else { fmt.Printf("Successfully created backup \"%s\" of index \"%s\".", backup.BackupId, index.Name) }
func (*Client) CreateCollection ¶
func (c *Client) CreateCollection(ctx context.Context, in *CreateCollectionRequest) (*Collection, error)
Client.CreateCollection creates and initializes a new Collection via the specified Client.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a CreateCollectionRequest object.
Note: Collections are only available for pods-based Indexes.
Returns a pointer to a Collection object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } collection, err := pc.CreateCollection(ctx, &pinecone.CreateCollectionRequest{ Name: "my-collection", Source: "my-source-index", }) if err != nil { log.Fatalf("Failed to create collection: %v", err) } else { fmt.Printf("Successfully created collection \"%s\".", collection.Name) }
func (*Client) CreateIndexForModel ¶
func (c *Client) CreateIndexForModel(ctx context.Context, in *CreateIndexForModelRequest) (*Index, error)
Client.CreateIndexForModel creates and initializes a new serverless Index via the specified Client that is configured for use with one of Pinecone's integrated inference models. After the index is created, you can upsert and search for records using the IndexConnection.UpsertRecords and IndexConnection.SearchRecords methods.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a CreateIndexForModelRequest object. See CreateIndexForModelRequest for more information.
Returns a pointer to an Index object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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" idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{ Name: indexName, Dimension: 3, Metric: pinecone.Cosine, Cloud: pinecone.Aws, Region: "us-east-1", }) if err != nil { log.Fatalf("Failed to create serverless index: %s", indexName) } else { fmt.Printf("Successfully created serverless index: %s", idx.Name) }
func (*Client) CreateIndexFromBackup ¶
func (c *Client) CreateIndexFromBackup(ctx context.Context, in *CreateIndexFromBackupParams) (*CreateIndexFromBackupResponse, error)
Client.CreateIndexFromBackup creates a new Index from a Backup.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a CreateIndexFromBackupParams object.
Note: Backups are only available for serverless Indexes.
Returns a pointer to a CreateIndexFromBackupResponse object or an error.
Example:
ctx := context.Background() pc, err := pinecone.NewClient(pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", }) if err != nil { log.Fatalf("Failed to create Client: %v", err) } else { fmt.Println("Successfully created a new Client object!") } createIndexFromBackupResp, err := pc.CreateIndexFromBackup(ctx, &pinecone.CreateIndexFromBackupParams{ BackupId: "my-backup-id", Name: "my-new-index-restored", }) if err != nil { log.Fatalf("Failed to create a new index from a backup: %v", err) } // retrieve the restore job restoreJob, err := pc.DescribeRestoreJob(ctx, createIndexFromBackupResp.RestoreJobId) if err != nil { log.Fatalf("Failed to describe restore job: %v", err) }
func (*Client) CreatePodIndex ¶
Client.CreatePodIndex creates and initializes a new pods-based Index via the specified Client.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a CreatePodIndexRequest object. See CreatePodIndexRequest for more information.
Returns a pointer to an Index object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } podIndexMetadata := &pinecone.PodSpecMetadataConfig{ Indexed: &[]string{"title", "description"}, } indexName := "my-pod-index" idx, err := pc.CreatePodIndex(ctx, &pinecone.CreatePodIndexRequest{ Name: indexName, Dimension: 3, Metric: pinecone.Cosine, Environment: "us-west1-gcp", PodType: "s1", MetadataConfig: podIndexMetadata, }) if err != nil { log.Fatalf("Failed to create pod index:", err) } else { fmt.Printf("Successfully created pod index: %s", idx.Name) }
func (*Client) CreateServerlessIndex ¶
func (c *Client) CreateServerlessIndex(ctx context.Context, in *CreateServerlessIndexRequest) (*Index, error)
Client.CreateServerlessIndex creates and initializes a new serverless Index via the specified Client.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a CreateServerlessIndexRequest object. See CreateServerlessIndexRequest for more information.
Returns a pointer to an Index object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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" idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{ Name: indexName, Dimension: 3, Metric: pinecone.Cosine, Cloud: pinecone.Aws, Region: "us-east-1", }) if err != nil { log.Fatalf("Failed to create serverless index: %s", indexName) } else { fmt.Printf("Successfully created serverless index: %s", idx.Name) }
func (*Client) DeleteBackup ¶
Client.DeleteBackup deletes a specific Backup by ID.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A string representing the ID of the Backup to delete.
Returns an error if the deletion fails.
Example:
ctx := context.Background() pc, err := pinecone.NewClient(pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", }) if err != nil { log.Fatalf("Failed to create Client: %w", err) } err := pc.DeleteBackup(ctx, "my-backup-id")) if err != nil { log.Fatalf("Failed to delete backup: %w", err) }
func (*Client) DeleteCollection ¶
Client.DeleteCollection deletes a specific Collection
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- collectionName: The name of the Collection to delete.
Note: Collections are only available for pods-based Indexes.
Returns an error if the deletion fails.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } collectionName := "my-collection" err = pc.DeleteCollection(ctx, collectionName) if err != nil { log.Fatalf("Failed to create collection: %s\n", err) } else { log.Printf("Successfully deleted collection \"%s\"\n", collectionName) }
func (*Client) DeleteIndex ¶
Client.DeleteIndex deletes a specific Index.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- idxName: The name of the Index to delete.
Returns an error if the deletion fails.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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 := "the-name-of-my-index" err = pc.DeleteIndex(ctx, indexName) if err != nil { log.Fatalf("Error: %v", err) } else { fmt.Printf("Index \"%s\" deleted successfully", indexName) }
func (*Client) DescribeBackup ¶
Client.DescribeBackup describes a specific Backup by ID.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A string representing the ID of the Backup to describe.
Returns a pointer to a Backup object or an error.
Example:
ctx := context.Background() pc, err := pinecone.NewClient(pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", }) if err != nil { log.Fatalf("Failed to create Client: %v", err) } else { fmt.Println("Successfully created a new Client object!") } backup, err := pc.DescribeBackup(ctx, "my-backup-id") if err != nil { log.Fatalf("Failed to describe backup ID %s: %w", "my-backup-id", err) }
func (*Client) DescribeCollection ¶
func (c *Client) DescribeCollection(ctx context.Context, collectionName string) (*Collection, error)
Client.DescribeCollection retrieves information about a specific Collection. See understanding collections for more information.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- collectionName: The name of the Collection to describe.
Returns a pointer to a Collection object or an error.
Note: Collections are only available for pods-based Indexes.
Since the returned value is a pointer to a Collection object, it will have the following fields:
- Name: The name of the Collection.
- Size: The size of the Collection in bytes.
- Status: The status of the Collection.
- Dimension: The dimensionality of the vectors stored in each record held in the Collection.
- VectorCount: The number of records stored in the Collection.
- Environment: The cloud environment where the Collection is hosted.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } collection, err := pc.DescribeCollection(ctx, "my-collection") if err != nil { log.Fatalf("Error describing collection: %v", err) } else { fmt.Printf("Collection: %+v\n", *collection) }
func (*Client) DescribeIndex ¶
Client.DescribeIndex retrieves information about a specific Index. See Index for more information.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- idxName: The name of the Index to describe.
Returns a pointer to an Index object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } idx, err := pc.DescribeIndex(ctx, "the-name-of-my-index") if err != nil { log.Fatalf("Failed to describe index: %s", err) } else { desc := fmt.Sprintf("Description: \n Name: %s\n Dimension: %d\n Host: %s\n Metric: %s\n"+ " DeletionProtection"+ ": %s\n"+ " Spec: %+v"+ "\n Status: %+v\n", idx.Name, idx.Dimension, idx.Host, idx.Metric, idx.DeletionProtection, idx.Spec, idx.Status) fmt.Println(desc) }
func (*Client) DescribeRestoreJob ¶
Client.DescribeRestoreJob describes a specific RestoreJob by ID.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A string representing the ID of the Backup to describe.
Returns a pointer to a Backup object or an error.
Example:
ctx := context.Background() pc, err := pinecone.NewClient(pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", }) if err != nil { log.Fatalf("Failed to create Client: %v", err) } else { fmt.Println("Successfully created a new Client object!") } restoreJob, err := pc.DescribeRestoreJob(ctx, "my-restore-job-id") if err != nil { log.Fatalf("Failed to describe restore job ID %s: %w", "my-restore-job-id", err) }
func (*Client) Index ¶
func (c *Client) Index(in NewIndexConnParams, dialOpts ...grpc.DialOption) (*IndexConnection, error)
Client.Index creates an IndexConnection to a specified host.
Parameters:
- in: A NewIndexConnParams object that includes the necessary configuration to create an IndexConnection. See NewIndexConnParams for more information.
Note: It is important to handle the error returned by this method to ensure that the IndexConnection is created successfully before making data plane calls.
Returns a pointer to an IndexConnection instance or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } else { fmt.Printf("Successfully found the \"%s\" index!\n", idx.Name) } indexConnParams := pinecone.NewIndexConnParams{ Host: idx.Host, Namespace: "your-namespace", AdditionalMetadata: map[string]string{ "your-metadata-key": "your-metadata-value", }, } idxConnection, err := pc.Index(indexConnParams) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } else { log.Println("IndexConnection created successfully!") }
func (*Client) ListBackups ¶
func (c *Client) ListBackups(ctx context.Context, in *ListBackupsParams) (*BackupList, error)
Client.ListBackups lists backups for a specific Index, or all of the backups in a Pinecone project.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a ListBackupsParams object.
Returns a pointer to a BackupList object or an error.
Example:
ctx := context.Background() pc, err := pinecone.NewClient(pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", }) if err != nil { log.Fatalf("Failed to create Client: %w", err) } indexName := "my-index" limit := 5 backups, err := pc.ListBackups(ctx, &pinecone.ListBackupsParams{ IndexName: &indexName, Limit: &limit, }) if err != nil { log.Fatalf("Failed to list backups: %w", err) }
func (*Client) ListCollections ¶
func (c *Client) ListCollections(ctx context.Context) ([]*Collection, error)
Client.ListCollections retrieves a list of all Collections in a Pinecone project. See understanding collections for more information.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
Returns a slice of pointers to Collection objects or an error.
Note: Collections are only available for pods-based Indexes.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } collections, err := pc.ListCollections(ctx) if err != nil { log.Fatalf("Failed to list collections: %v", err) } else { if len(collections) == 0 { fmt.Printf("No collections found in project") } else { fmt.Println("Collections in project:") for _, collection := range collections { fmt.Printf("- %s\n", collection.Name) } } }
func (*Client) ListIndexes ¶
Client.ListIndexes retrieves a list of all Indexes in a Pinecone project.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
Returns a slice of pointers to Index objects or an error.
Example:
clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } idxs, err := pc.ListIndexes(ctx) if err != nil { log.Fatalf("Failed to list indexes: %v", err) } else { fmt.Println("Your project has the following indexes:") for _, idx := range idxs { fmt.Printf("- \"%s\"\n", idx.Name) } }
func (*Client) ListRestoreJobs ¶
func (c *Client) ListRestoreJobs(ctx context.Context, in *ListRestoreJobsParams) (*RestoreJobList, error)
Client.ListRestoreJobs lists all restore jobs in a Pinecone project.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a ListRestoreJobsParams object.
Returns a pointer to a RestoreJobList object or an error.
Example:
ctx := context.Background() pc, err := pinecone.NewClient(pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", }) if err != nil { log.Fatalf("Failed to create Client: %w", err) } indexName := "my-index" limit := 5 restoreJobs, err := pc.ListRestoreJobs(ctx, &pinecone.ListRestoreJobsParams{ IndexName: &indexName, Limit: &limit, }) if err != nil { log.Fatalf("Failed to list restore jobs: %w", err) }
type Cloud ¶
type Cloud string
Cloud is the cloud provider to be used for a Pinecone serverless Index.
type Collection ¶
type Collection struct { Name string `json:"name"` Size int64 `json:"size"` Status CollectionStatus `json:"status"` Dimension int32 `json:"dimension"` VectorCount int32 `json:"vector_count"` Environment string `json:"environment"` }
Collection is a Pinecone collection entity. Only available for pod-based Indexes.
Fields:
- Name: The name of the collection.
- Size: The total size of the collection in bytes.
- Status: The CollectionStatus of the collection.
- Dimension: The dimensionality of the each vectors for each record stored in the collection.
- VectorCount: The number of records (vectors) stored in the collection.
- Environment: The environment where the collection is hosted.
type CollectionStatus ¶
type CollectionStatus string
CollectionStatus is the status of a Pinecone Collection.
const ( CollectionStatusInitializing CollectionStatus = "Initializing" CollectionStatusReady CollectionStatus = "Ready" CollectionStatusTerminating CollectionStatus = "Terminating" )
type ConfigureIndexEmbed ¶
type ConfigureIndexEmbed struct { FieldMap *map[string]interface{} Model *string ReadParameters *map[string]interface{} WriteParameters *map[string]interface{} }
ConfigureIndexEmbed contains parameters for configuring the integrated inference embedding settings for an Index. You can convert an existing serverless index to an integrated index by specifying the Model and FieldMap. The index vector type and dimension must match the model vector type and dimension, and the index similarity metric must be supported by the model. Refer to the [model guide](https://docs.pinecone.io/guides/inference/understanding-inference#embedding-models) for available models and model details.
You can later change the embedding configuration to update the field map, read parameters, or write parameters. Once set, the model cannot be changed.
Fields:
- FieldMap: (Optional) Identifies the name of the text field from your document model that will be embedded.
- Model: (Optional) The name of the embedding model to use with the index.
- ReadParameters: (Optional) The read parameters for the embedding model.
- WriteParameters: (Optional) The write parameters for the embedding model.
type ConfigureIndexParams ¶
type ConfigureIndexParams struct { PodType string Replicas int32 DeletionProtection DeletionProtection Tags IndexTags Embed *ConfigureIndexEmbed }
ConfigureIndexParams contains parameters for configuring an Index. For both pod-based and serverless indexes you can configure the DeletionProtection status for an Index. For pod-based indexes you can also configure the number of Replicas and the PodType. Each of the fields is optional, but at least one field must be set. See scale a pods-based index for more information.
Fields:
- PodType: (Optional) The pod size to scale the index to. For a "p1" pod type, you could pass "p1.x2" to scale your index to the "x2" size, or you could pass "p1.x4" to scale your index to the "x4" size, and so forth. Only applies to pod-based indexes.
- Replicas: (Optional) The number of replicas to scale the index to. This is capped by the maximum number of replicas allowed in your Pinecone project. To configure this number, go to app.pinecone.io, select your project, and configure the maximum number of pods.
- DeletionProtection: (Optional) DeletionProtection determines whether deletion protection is "enabled" or "disabled" for the index. When "enabled", the index cannot be deleted. Defaults to "disabled".
- Tags: (Optional) A map of tags to associate with the Index.
- Embed: (Optional) The ConfigureIndexEmbed object for integrated index configuration.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } idx, err := pc.ConfigureIndex(ctx, "my-index", ConfigureIndexParams{ DeletionProtection: "enabled", Replicas: 4 })
type CreateAPIKeyParams ¶ added in v4.1.0
type CreateAPIKeyParams struct { // The name of the API key. The name must be 1-80 characters long. Name string `json:"name"` // (Optional) The roles to create the API key with. // Expected values: "ProjectEditor", "ProjectViewer", "ControlPlaneEditor", "ControlPlaneViewer", "DataPlaneEditor", "DataPlaneViewer" // Default is `["ProjectEditor"]`. Roles *[]string `json:"roles,omitempty"` }
CreateAPIKeyParams contains parameters for creating a new API key.
type CreateBackupParams ¶
type CreateBackupParams struct { IndexName string `json:"index_name"` Description *string `json:"description,omitempty"` Name *string `json:"name,omitempty"` }
CreateBackupParams contains the input parameters for creating a backup of a Pinecone index.
Fields:
- IndexName: The unique name of the index to back up.
- Description: Optional description of the backup.
- Name: Optional name for the backup.
type CreateCollectionRequest ¶
CreateCollectionRequest holds the parameters for creating a new Collection.
Fields:
- Name: (Required) The name of the Collection.
- Source: (Required) The name of the Index to be used as the source for the Collection.
To create a new Collection, use the Client.CreateCollection method.
Note: Collections are only available for pods-based Indexes.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } collection, err := pc.CreateCollection(ctx, &pinecone.CreateCollectionRequest{ Name: "my-collection", Source: "my-source-index", }) if err != nil { log.Fatalf("Failed to create collection: %v", err) } else { fmt.Printf("Successfully created collection \"%s\".", collection.Name) }
type CreateIndexForModelEmbed ¶
type CreateIndexForModelEmbed struct { Model string FieldMap map[string]interface{} Dimension *int Metric *IndexMetric ReadParameters *map[string]interface{} WriteParameters *map[string]interface{} }
CreateIndexForModelEmbed defines the embedding model configuration for an index.
Fields:
- Model: (Required) The name of the embedding model to use for the index.
- FieldMap: (Required) Identifies the name of the text field from your document model that will be embedded.
- Dimension: (Optional) The dimensionality of the vectors to be inserted in the Index. If not specified, the dimension will be defaulted according to the model.
- Metric: (Optional) The similarity metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. If not specified, the metric will be defaulted according to the model. Cannot be updated once set.
- ReadParameters: (Optional) Read parameters for the embedding model.
- WriteParameters: (Optional) Write parameters for the embedding model.
The `CreateIndexForModelEmbed` struct is used as part of the CreateIndexForModelRequest when creating an index with an associated embedding model. Once an index is created, the `model` field cannot be changed, but other configurations such as `field_map`, `read_parameters`, and `write_parameters` can be updated.
type CreateIndexForModelRequest ¶
type CreateIndexForModelRequest struct { Name string Cloud Cloud Region string DeletionProtection *DeletionProtection Embed CreateIndexForModelEmbed Tags *IndexTags }
CreateIndexForModelRequest defines the desired configuration for creating an index with an associated embedding model.
Fields:
- Name: (Required) The name of the Index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
- Cloud: (Required) The public cloud provider where you would like your Index hosted.
- Region: (Required) The region where you would like your Index to be created.
- DeletionProtection: (Optional) Whether deletion protection is enabled or disabled for the index. When enabled, the index cannot be deleted. Defaults to disabled.
- Embed: (Required) The CreateIndexForModelEmbed object for embedding model configuration. Once set, the model cannot be changed, but embedding configurations such as field map, read parameters, or write parameters can be updated.
- FieldMap: Identifies the name of the text field from your document model that will be embedded.
- Metric: The similarity metric to be used for similarity search. Options: 'euclidean', 'cosine', or 'dotproduct'. If not specified, the metric will default according to the model and cannot be updated once set.
- Model: The name of the embedding model to use for the index.
- ReadParameters: The read parameters for the embedding model.
- WriteParameters: The write parameters for the embedding model.
- Tags: (Optional) Custom user tags added to an index. Keys must be 80 characters or less, values must be 120 characters or less. Keys must be alphanumeric, '_', or '-'. Values must be alphanumeric, ';', '@', '_', '-', '.', '+', or ' '. To unset a key, set the value to be an empty string.
To create an index with an associated embedding model, use the Client.CreateIndexForModel method.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } request := &pinecone.CreateIndexForModelRequest{ Name: "my-index", Cloud: pinecone.Aws, Region: "us-east-1", Embed: CreateIndexForModelEmbed{ Model: "multilingual-e5-large", FieldMap: map[string]interface{}{"text": "chunk_text"}, }, } idx, err := pc.CreateIndexForModel(ctx, request) if err != nil { log.Fatalf("Failed to create index: %v", err) } else { fmt.Printf("Successfully created index: %s", idx.Name) }
type CreateIndexFromBackupParams ¶
type CreateIndexFromBackupParams struct { BackupId string `json:"backup_id"` Name string `json:"name"` DeletionProtection *DeletionProtection `json:"deletion_protection,omitempty"` Tags *IndexTags `json:"tags,omitempty"` }
CreateIndexFromBackupParams contains the parameters needed to create a Pinecone index from a backup.
Fields:
- BackupId: The unique identifier of the backup to restore from.
- Name: The name of the index to be created. Must be 1–45 characters, lowercase alphanumeric or '-'.
- DeletionProtection: Optional value configuring deletion protection for the new index. Can be either 'enabled' or 'disabled'.
- Tags: Optional custom user tags added to an index. Keys must be 80 characters or less. Values must be 120 characters or less. Keys must be alphanumeric, '_', or '-'. Values must be alphanumeric, ';', '@', '_', '-', '.', '+', or ' '. To unset a key, set the value to be an empty string.
type CreateIndexFromBackupResponse ¶
type CreateIndexFromBackupResponse struct { IndexId string `json:"index_id"` RestoreJobId string `json:"restore_job_id"` }
CreateIndexFromBackupResponse contains the response returned after creating an index from a backup. RestoreJobId can be used to track the progress of an index restoration through the Client.DescribeRestoreJob method.
Fields:
- IndexId: The ID of the index that was created from the backup.
- RestoreJobId: The ID of the restore job initiated to restore the backup.
type CreatePodIndexRequest ¶
type CreatePodIndexRequest struct { Name string Dimension int32 Environment string PodType string Shards int32 Replicas int32 Metric *IndexMetric DeletionProtection *DeletionProtection SourceCollection *string MetadataConfig *PodSpecMetadataConfig Tags *IndexTags }
CreatePodIndexRequest holds the parameters for creating a new pods-based Index.
Fields:
- Name: (Required) The name of the Index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
- Dimension: (Required) The dimensionality of the vectors to be inserted in the Index.
- Metric: (Required) The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. Defaults to 'cosine'.
- DeletionProtection: (Optional) determines whether deletion protection is "enabled" or "disabled" for the index. When "enabled", the index cannot be deleted. Defaults to "disabled".
- Environment: (Required) The cloud environment where the Index will be hosted.
- PodType: (Required) The type of pod to use for the Index. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.
- Shards: (Optional) The number of shards to use for the Index (defaults to 1). Shards split your data across multiple pods, so you can fit more data into an Index.
- Replicas: (Optional) The number of replicas to use for the Index (defaults to 1). Replicas duplicate your Index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change.
- SourceCollection: (Optional) The name of the Collection to be used as the source for the Index.
- MetadataConfig: (Optional) The metadata configuration for the behavior of Pinecone's internal metadata Index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed. These configurations are only valid for use with pod-based Indexes.
- Tags: (Optional) A map of tags to associate with the Index.
To create a new pods-based Index, use the Client.CreatePodIndex method.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } podIndexMetadata := &pinecone.PodSpecMetadataConfig{ Indexed: &[]string{"title", "description"}, } indexName := "my-pod-index" idx, err := pc.CreatePodIndex(ctx, &pinecone.CreatePodIndexRequest{ Name: indexName, Dimension: 3, Metric: pinecone.Cosine, Environment: "us-west1-gcp", PodType: "s1", MetadataConfig: podIndexMetadata, }) if err != nil { log.Fatalf("Failed to create pod index: %v", err) } else { fmt.Printf("Successfully created pod index: %s", idx.Name) }
func (CreatePodIndexRequest) ReplicaCount ¶
func (req CreatePodIndexRequest) ReplicaCount() int32
[CreatePodIndexRequestReplicaCount] ensures the replica count of a pods-based Index is >1. It returns a pointer to the number of replicas on a CreatePodIndexRequest object.
func (CreatePodIndexRequest) ShardCount ¶
func (req CreatePodIndexRequest) ShardCount() int32
[CreatePodIndexRequestShardCount] ensures the number of shards on a pods-based Index is >1. It returns a pointer to the number of shards on a CreatePodIndexRequest object.
func (CreatePodIndexRequest) TotalCount ¶
func (req CreatePodIndexRequest) TotalCount() int
CreatePodIndexRequest.TotalCount calculates and returns the total number of pods (replicas*shards) on a CreatePodIndexRequest object.
type CreateProjectParams ¶ added in v4.1.0
type CreateProjectParams struct { // The name of the new project. Name string `json:"name"` // (Optional) Whether to force encryption with a customer-managed encryption key (CMEK). Default is `false`. // Once enabled, CMEK encryption cannot be disabled. ForceEncryptionWithCmek *bool `json:"force_encryption_with_cmek,omitempty"` // (Optional) The maximum number of Pods that can be created in the project. Default is `0` (serverless only). MaxPods *int `json:"max_pods,omitempty"` }
CreateProjectParams contains parameters for creating a new project.
type CreateServerlessIndexRequest ¶
type CreateServerlessIndexRequest struct { Name string Cloud Cloud Region string Metric *IndexMetric DeletionProtection *DeletionProtection Dimension *int32 VectorType *string Tags *IndexTags SourceCollection *string }
CreateServerlessIndexRequest holds the parameters for creating a new Serverless Index.
Fields:
- Name: (Required) The name of the Index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
- Cloud: (Required) The public cloud provider where you would like your Index hosted. For serverless Indexes, you define only the cloud and region where the Index should be hosted.
- Region: (Required) The region where you would like your Index to be created.
- Metric: (Optional) The metric used to measure the similarity between vectors ('euclidean', 'cosine', or 'dotproduct'). Defaults to `cosine` or `dotproduct` depending on the VectorType.
- DeletionProtection: (Optional) Determines whether deletion protection is "enabled" or "disabled" for the index. When "enabled", the index cannot be deleted. Defaults to "disabled".
- Dimension: (Optional) The dimensionality of the vectors to be inserted in the Index.
- VectorType: (Optional) The index vector type. You can use `dense` or `sparse`. If `dense`, the vector dimension must be specified. If `sparse`, the vector dimension should not be specified, and the Metric must be set to `dotproduct`. Defaults to `dense`.
- Tags: (Optional) A map of tags to associate with the Index.
- SourceCollection: (Optional) The name of the Collection to use as the source for the index. NOTE: Collections can only be created from pods-based indexes.
To create a new Serverless Index, use the Client.CreateServerlessIndex method.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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" idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{ Name: indexName, Dimension: 3, Metric: pinecone.Cosine, Cloud: pinecone.Aws, Region: "us-east-1", }) if err != nil { log.Fatalf("Failed to create serverless index: %s", indexName) } else { fmt.Printf("Successfully created serverless index: %s", idx.Name) }
type DefaultApiKeyClient ¶ added in v4.1.3
type DefaultApiKeyClient struct {
// contains filtered or unexported fields
}
DefaultApiKeyClient is the default implementation of APIKeyClient.
func (*DefaultApiKeyClient) Create ¶ added in v4.1.3
func (a *DefaultApiKeyClient) Create(ctx context.Context, projectId string, in *CreateAPIKeyParams) (*APIKeyWithSecret, error)
Creates a new API key.
Parameters:
- ctx: The request context.
- projectId: The ID of the project in which to create the API key.
- in: A pointer to CreateAPIKeyParams containing the API key configuration.
Returns a pointer to an APIKeyWithSecret or an error.
Example:
apiKeyWithSecret, err := adminClient.APIKey.Create(ctx, "project-id", &pinecone.CreateAPIKeyParams{ Name: "my-api-key", }) if err != nil { log.Fatal(err) }
func (*DefaultApiKeyClient) Delete ¶ added in v4.1.3
func (a *DefaultApiKeyClient) Delete(ctx context.Context, apiKeyId string) error
Deletes an API key by ID.
Parameters:
- ctx: The request context.
- apiKeyId: The ID of the API key to delete.
Returns an error if deletion fails.
Example:
err := adminClient.APIKey.Delete(ctx, "api-key-id") if err != nil { log.Fatal(err) }
func (*DefaultApiKeyClient) Describe ¶ added in v4.1.3
Describes an API key by ID.
Parameters:
- ctx: The request context.
- apiKeyId: The ID of the API key to describe.
Returns a pointer to an APIKey or an error.
Example:
apiKey, err := adminClient.APIKey.Describe(ctx, "api-key-id") if err != nil { log.Fatal(err) }
func (*DefaultApiKeyClient) List ¶ added in v4.1.3
Lists all API keys within a project by project ID.
Parameters:
- ctx: The request context.
- projectId: The ID of the project to list API keys for.
Returns a slice of APIKey objects or an error.
Example:
apiKeys, err := adminClient.APIKey.List(ctx, "project-id") if err != nil { log.Fatal(err) }
func (*DefaultApiKeyClient) Update ¶ added in v4.1.3
func (a *DefaultApiKeyClient) Update(ctx context.Context, apiKeyId string, in *UpdateAPIKeyParams) (*APIKey, error)
Updates an existing API key by ID.
Parameters:
- ctx: The request context.
- apiKeyId: The ID of the API key to update.
- in: A pointer to UpdateAPIKeyParams containing updated fields.
Returns the updated APIKey or an error.
Example:
apiKey, err := adminClient.APIKey.Update(ctx, "api-key-id", &pinecone.UpdateAPIKeyParams{ Name: "updated-name", }) if err != nil { log.Fatal(err) }
type DefaultOrganizationClient ¶ added in v4.1.3
type DefaultOrganizationClient struct {
// contains filtered or unexported fields
}
DefaultOrganizationClient is the default implementation of OrganizationClient.
func (*DefaultOrganizationClient) Delete ¶ added in v4.1.3
func (o *DefaultOrganizationClient) Delete(ctx context.Context, organizationId string) error
Deletes an organization by ID. All projects within the organization must be deleted first.
Parameters:
- ctx: The request context.
- organizationId: The ID of the organization to delete.
Returns an error if deletion fails.
Example:
err := adminClient.Organization.Delete(ctx, "organization-id") if err != nil { log.Fatal(err) }
func (*DefaultOrganizationClient) Describe ¶ added in v4.1.3
func (o *DefaultOrganizationClient) Describe(ctx context.Context, organizationId string) (*Organization, error)
Describes an organization by ID.
Parameters:
- ctx: The request context.
- organizationId: The ID of the organization to describe.
Returns a pointer to an Organization or an error.
Example:
org, err := adminClient.Organization.Describe(ctx, "organization-id") if err != nil { log.Fatal(err) }
func (*DefaultOrganizationClient) List ¶ added in v4.1.3
func (o *DefaultOrganizationClient) List(ctx context.Context) ([]*Organization, error)
Lists all organizations available to the authenticated service account.
Parameters:
- ctx: The request context.
Returns a slice of Organization objects or an error.
Example:
orgs, err := adminClient.Organization.List(ctx) if err != nil { log.Fatal(err) }
func (*DefaultOrganizationClient) Update ¶ added in v4.1.3
func (o *DefaultOrganizationClient) Update(ctx context.Context, organizationId string, in *UpdateOrganizationParams) (*Organization, error)
Updates an existing organization by ID.
Parameters:
- ctx: The request context.
- organizationId: The ID of the organization to update.
- in: A pointer to UpdateOrganizationParams containing updated fields.
Returns the updated Organization or an error.
Example:
org, err := adminClient.Organization.Update(ctx, "organization-id", &pinecone.UpdateOrganizationParams{ Name: "Renamed Org", }) if err != nil { log.Fatal(err) }
type DefaultProjectClient ¶ added in v4.1.3
type DefaultProjectClient struct {
// contains filtered or unexported fields
}
DefaultProjectClient is the default implementation of ProjectClient.
func (*DefaultProjectClient) Create ¶ added in v4.1.3
func (p *DefaultProjectClient) Create(ctx context.Context, in *CreateProjectParams) (*Project, error)
Creates a new project.
Parameters:
- ctx: The request context.
- in: A pointer to CreateProjectParams containing the new project's configuration.
Returns a pointer to a Project or an error.
Example:
ctx := context.Background() project, err := adminClient.Project.Create(ctx, &pinecone.CreateProjectParams{ Name: "example-project", }) if err != nil { log.Fatal(err) }
func (*DefaultProjectClient) Delete ¶ added in v4.1.3
func (p *DefaultProjectClient) Delete(ctx context.Context, projectId string) error
Deletes a project by ID.
Parameters:
- ctx: The request context.
- projectId: The ID of the project to delete.
Returns an error if deletion fails.
Example:
err := adminClient.Project.Delete(ctx, "project-id") if err != nil { log.Fatal(err) }
func (*DefaultProjectClient) Describe ¶ added in v4.1.3
Describes an existing project by ID.
Parameters:
- ctx: The request context.
- projectId: The ID of the project to describe.
Returns a pointer to a Project or an error.
Example:
project, err := adminClient.Project.Describe(ctx, "project-id") if err != nil { log.Fatal(err) }
func (*DefaultProjectClient) List ¶ added in v4.1.3
func (p *DefaultProjectClient) List(ctx context.Context) ([]*Project, error)
Lists all projects available to the authenticated service account.
Parameters:
- ctx: The request context.
Returns a slice of Project objects or an error.
Example:
projects, err := adminClient.Project.List(ctx) if err != nil { log.Fatal(err) }
func (*DefaultProjectClient) Update ¶ added in v4.1.3
func (p *DefaultProjectClient) Update(ctx context.Context, projectId string, in *UpdateProjectParams) (*Project, error)
Updates an existing project by ID.
Parameters:
- ctx: The request context.
- projectId: The ID of the project to update.
- in: A pointer to UpdateProjectParams containing the updated project configuration.
Returns the updated Project or an error.
Example:
project, err := adminClient.Project.Update(ctx, "project-id", &pinecone.UpdateProjectParams{ Name: "renamed-project", }) if err != nil { log.Fatal(err) }
type DeletionProtection ¶
type DeletionProtection string
DeletionProtection determines whether deletion protection is "enabled" or "disabled" for the Index. When "enabled", the Index cannot be deleted. Defaults to "disabled".
const ( DeletionProtectionEnabled DeletionProtection = "enabled" DeletionProtectionDisabled DeletionProtection = "disabled" )
type DenseEmbedding ¶
type DenseEmbedding struct { VectorType string `json:"vector_type"` Values []float32 `json:"values"` }
DenseEmbedding represents a dense numerical embedding of the input.
Fields:
- VectorType: A string indicating the type of vector embedding ("dense").
- Values: A slice of float32 values representing the dense embedding.
type DescribeIndexStatsResponse ¶
type DescribeIndexStatsResponse struct { Dimension *uint32 `json:"dimension"` IndexFullness float32 `json:"index_fullness"` TotalVectorCount uint32 `json:"total_vector_count"` Namespaces map[string]*NamespaceSummary `json:"namespaces,omitempty"` }
DescribeIndexStatsResponse is returned by the IndexConnection.DescribeIndexStats method.
Fields:
type Document ¶
type Document map[string]interface{}
Document is a map representing the document to be reranked.
type EmbedParameters ¶
type EmbedParameters map[string]interface{}
EmbedParameters contains model-specific parameters that can be used for generating embeddings.
Fields:
- InputType: (Optional) A common property used to distinguish between different types of data. For example, "passage", or "query".
- Truncate: (Optional) How to handle inputs longer than those supported by the model. if "NONE", when the input exceeds the maximum input token length, an error will be returned.
type EmbedRequest ¶
type EmbedRequest struct { Model string TextInputs []string Parameters EmbedParameters }
EmbedRequest holds the parameters for generating embeddings for a list of input strings.
Fields:
- Model: (Required) The model to use for generating embeddings.
- TextInputs: (Required) A list of strings to generate embeddings for.
- Parameters: (Optional) EmbedParameters object that contains additional parameters to use when generating embeddings.
type EmbedResponse ¶
type EmbedResponse struct { Data []Embedding `json:"data"` Model string `json:"model"` Usage struct { TotalTokens *int32 `json:"total_tokens,omitempty"` } `json:"usage"` }
EmbedResponse represents holds the embeddings generated for a single input.
Fields:
- Data: A list of Embedding objects containing the embeddings generated for the input.
- Model: The model used to generate the embeddings.
- Usage: Usage statistics (Total Tokens) for the request.
type Embedding ¶
type Embedding struct { SparseEmbedding *SparseEmbedding `json:"sparse_embedding,omitempty"` DenseEmbedding *DenseEmbedding `json:"dense_embedding,omitempty"` }
Embedding represents the embedding of a single input which is returned after [generating embeddings]. Embedding is a tagged union which can have either a SparseEmbedding or a DenseEmbedding.
[generating embeddings]: https://docs.pinecone.io/guides/inference/generate-embeddings#3-generate-embeddings Fields:
- SparseEmbedding: The SparseEmbedding representation of the input.
- DenseEmbedding: The DenseEmbedding representation of the input.
type FetchVectorsResponse ¶
type FetchVectorsResponse struct { Vectors map[string]*Vector `json:"vectors,omitempty"` Usage *Usage `json:"usage,omitempty"` Namespace string `json:"namespace"` }
FetchVectorsResponse is returned by the IndexConnection.FetchVectors method.
Fields:
- Vectors: The vectors fetched.
- Usage: The usage information for the request.
- Namespace: The namespace from which the vectors were fetched.
type Hit ¶
type Hit struct { Id string `json:"_id"` Score float32 `json:"_score"` Fields map[string]interface{} `json:"fields"` }
Hit represents a record whose vector values are similar to the provided search query.
Fields:
- Id: The record ID of the search hit.
- Score: The similarity score of the returned record.
- Fields: The selected record fields associated with the search hit.
type Import ¶
type Import struct { Id string `json:"id,omitempty"` PercentComplete float32 `json:"percent_complete,omitempty"` RecordsImported int64 `json:"records_imported,omitempty"` Status ImportStatus `json:"status,omitempty"` Uri string `json:"uri,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` FinishedAt *time.Time `json:"finished_at,omitempty"` Error *string `json:"error,omitempty"` }
Import represents the details and status of an import process.
Fields:
- Id: The unique identifier of the Import process.
- PercentComplete: The percentage of the Import process that has been completed.
- RecordsImported: The total number of records successfully imported.
- Status: The current status of the Import (e.g., "InProgress", "Completed", "Failed").
- Uri: The URI of the source data for the Import.
- CreatedAt: The time at which the Import process was initiated.
- FinishedAt: The time at which the Import process finished (either successfully or with an error).
- Error: If the Import failed, contains the error message associated with the failure.
type ImportErrorMode ¶
type ImportErrorMode string
ImportErrorMode specifies how errors are handled during an Import.
Values:
- Abort: The Import process will abort upon encountering an error.
- Continue: The Import process will continue, skipping over records that produce errors.
const ( Abort ImportErrorMode = "abort" Continue ImportErrorMode = "continue" )
type ImportStatus ¶
type ImportStatus string
ImportStatus represents the status of an Import operation.
Values:
- Cancelled: The Import was canceled.
- Completed: The Import completed successfully.
- Failed: The Import encountered an error and did not complete successfully.
- InProgress: The Import is currently in progress.
- Pending: The Import is pending and has not yet started.
const ( Cancelled ImportStatus = "Cancelled" Completed ImportStatus = "Completed" Failed ImportStatus = "Failed" InProgress ImportStatus = "InProgress" Pending ImportStatus = "Pending" )
type Index ¶
type Index struct { Name string `json:"name"` Host string `json:"host"` Metric IndexMetric `json:"metric"` VectorType string `json:"vector_type"` DeletionProtection DeletionProtection `json:"deletion_protection,omitempty"` PrivateHost *string `json:"private_host,omitempty"` Dimension *int32 `json:"dimension,omitempty"` Spec *IndexSpec `json:"spec,omitempty"` Status *IndexStatus `json:"status,omitempty"` Tags *IndexTags `json:"tags,omitempty"` Embed *IndexEmbed `json:"embed,omitempty"` }
Index is a Pinecone Index object. Can be either a pod-based or a serverless Index, depending on the IndexSpec.
Fields:
- Name: The name of the index.
- Host: The URL address where the index is hosted.
- Metric: The distance metric used for similarity search. One of 'euclidean', 'cosine', or 'dotproduct'.
- VectorType: The index vector type. One of 'sparse' or 'dense'.
- DeletionProtection: Whether deletion protection is configured for the index. Can be 'enabled' or 'disabled'.
- PrivateHost: The private endpoint URL of an index.
- Dimension: The dimensions of vectors stored in the index. Required for dense indexes.
- Spec: The infrastructure configuration for the index. Contains either PodSpec or ServerlessSpec.
- Status: The IndexStatus of the index, which includes index state information.
- Tags: Custom IndexTags added to an index.
- Embed: The IndexEmbed model configured for the index, if applicable.
type IndexConnection ¶
type IndexConnection struct {
// contains filtered or unexported fields
}
IndexConnection holds the parameters for a Pinecone IndexConnection object. You can instantiate a IndexConnection by calling the Client.Index method with a NewIndexConnParams object. You can use IndexConnection.WithNamespace to create a new IndexConnection that targets a different namespace while sharing the underlying gRPC connection.
Fields:
- namespace: The namespace where index operations will be performed.
- additionalMetadata: Additional metadata to be sent with each RPC request.
- dataClient: The gRPC client for the index.
- grpcConn: The gRPC connection.
func (*IndexConnection) CancelImport ¶
func (idx *IndexConnection) CancelImport(ctx context.Context, id string) error
IndexConnection.CancelImport cancels an Import operation by id.
Returns an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- id: The id of the Import operation to cancel.
Example:
ctx := context.Background() clientParams := NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } err = idxConnection.CancelImport(ctx, "your-import-id") if err != nil { log.Fatalf("Failed to cancel import: %s", "your-import-id") }
func (*IndexConnection) Close ¶
func (idx *IndexConnection) Close() error
IndexConnection.Close closes the grpc.ClientConn to a Pinecone Index.
Returns an error if the connection cannot be closed, otherwise returns nil.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection: %v", err) } err = idxConnection.Close() if err != nil { log.Fatalf("Failed to close index connection. Error: %v", err) }
func (*IndexConnection) DeleteAllVectorsInNamespace ¶
func (idx *IndexConnection) DeleteAllVectorsInNamespace(ctx context.Context) error
IndexConnection.DeleteAllVectorsInNamespace deletes all vectors in a specific namespace.
Returns an error if the request fails, otherwise returns nil.
Note: You must instantiate an IndexConnection using the Client.Index method with a Namespace in NewIndexConnParams in order to delete vectors in a namespace other than the default: "".
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "your-namespace"}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } err = idxConnection.DeleteAllVectorsInNamespace(ctx) if err != nil { log.Fatalf("Failed to delete vectors in namespace: \"%s\". Error: %s", "your-namespace", err) }
func (*IndexConnection) DeleteNamespace ¶
func (idx *IndexConnection) DeleteNamespace(ctx context.Context, namespace string) error
IndexConnection.DeleteNamespace describes a namespace within a serverless index.
Returns an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- namespace: The unique name of the namespace to delete.
Example:
ctx := context.Background() clientParams := NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } err := pc.DeleteNamespace(ctx, "your-namespace-name") if err != nil { log.Fatalf("Failed to delete namespace \"%s\". Error:%s", "your-namespace-name", err) }
func (*IndexConnection) DeleteVectorsByFilter ¶
func (idx *IndexConnection) DeleteVectorsByFilter(ctx context.Context, metadataFilter *MetadataFilter) error
IndexConnection.DeleteVectorsByFilter deletes vectors from a Pinecone Index, given a filter.
Returns an error if the request fails, otherwise returns nil.
Note: [DeleteVectorsByFilter] is only available on pods-based indexes. Additionally, you must create an IndexConnection using the Client.Index method with a Namespace in NewIndexConnParams in order to delete vectors in a namespace other than the default: "".
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- MetadataFilter: The filter to apply to the deletion.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } MetadataFilter := map[string]interface{}{ "genre": "classical", } filter, err := structpb.NewStruct(MetadataFilter) if err != nil { log.Fatalf("Failed to create metadata filter. Error: %v", err) } err = idxConnection.DeleteVectorsByFilter(ctx, filter) if err != nil { log.Fatalf("Failed to delete vector(s) with filter: %+v. Error: %s\n", filter, err) }
func (*IndexConnection) DeleteVectorsById ¶
func (idx *IndexConnection) DeleteVectorsById(ctx context.Context, ids []string) error
IndexConnection.DeleteVectorsById deletes vectors by ID from a Pinecone Index.
Returns an error if the request fails, otherwise returns nil. This method will also return nil if the passed vector ID does not exist in the index or namespace.
Note: You must create an IndexConnection with a Namespace in NewIndexConnParams in order to delete vectors in a namespace other than the default: "".
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- ids: IDs of the vectors you want to delete.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "custom-namespace"}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } vectorId := "your-vector-id" err = idxConnection.DeleteVectorsById(ctx, []string{vectorId}) if err != nil { log.Fatalf("Failed to delete vector with ID: %s. Error: %s\n", vectorId, err) }
func (*IndexConnection) DescribeImport ¶
IndexConnection.DescribeImport retrieves information about a specific Import operation.
Returns a pointer to an Import object representing the current state of the import process, or an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- id: The id of the import operation. This is returned when you call IndexConnection.StartImport, or can be retrieved through the IndexConnection.ListImports method.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } importDesc, err := idxConnection.DescribeImport(ctx, "your-import-id") if err != nil { log.Fatalf("Failed to describe import: %s - %v", "your-import-id", err) } fmt.Printf("Import ID: %s, Status: %s", importDesc.Id, importDesc.Status)
func (*IndexConnection) DescribeIndexStats ¶
func (idx *IndexConnection) DescribeIndexStats(ctx context.Context) (*DescribeIndexStatsResponse, error)
IndexConnection.DescribeIndexStats returns statistics about a Pinecone Index.
Returns a pointer to a DescribeIndexStatsResponse object or an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index:", err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } res, err := idxConnection.DescribeIndexStats(ctx) if err != nil { log.Fatalf("Failed to describe index \"%s\". Error: %s", idx.Name, err) } else { log.Fatalf("%+v", *res) }
func (*IndexConnection) DescribeIndexStatsFiltered ¶
func (idx *IndexConnection) DescribeIndexStatsFiltered(ctx context.Context, metadataFilter *MetadataFilter) (*DescribeIndexStatsResponse, error)
IndexConnection.DescribeIndexStatsFiltered returns statistics about a Pinecone Index, filtered by a given filter.
Returns a pointer to a DescribeIndexStatsResponse object or an error if the request fails.
Note: DescribeIndexStatsFiltered is only available on pods-based indexes.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- MetadataFilter: The filter to apply to the request.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } MetadataFilter := map[string]interface{}{ "genre": "classical", } filter, err := structpb.NewStruct(MetadataFilter) if err != nil { log.Fatalf("Failed to create filter %+v. Error: %s", MetadataFilter, err) } res, err := idxConnection.DescribeIndexStatsFiltered(ctx, filter) if err != nil { log.Fatalf("Failed to describe index \"%s\". Error: %s", idx.Name, err) } else { for name, summary := range res.Namespaces { fmt.Printf("Namespace: \"%s\", has %d vector(s) that match the given filter\n", name, summary.VectorCount) } }
func (*IndexConnection) DescribeNamespace ¶
func (idx *IndexConnection) DescribeNamespace(ctx context.Context, namespace string) (*NamespaceDescription, error)
IndexConnection.DescribeNamespace describes a namespace within a serverless index.
Returns a pointer to a NamespaceDescription object or an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- namespace: The unique name of the namespace to describe.
Example:
ctx := context.Background() clientParams := NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } namespace, err := idxConnection.DescribeNamespace(ctx, "your-namespace-name") if err != nil { log.Fatalf("Failed to describe namespace \"%s\". Error:%s", "your-namespace-name", err) }
func (*IndexConnection) FetchVectors ¶
func (idx *IndexConnection) FetchVectors(ctx context.Context, ids []string) (*FetchVectorsResponse, error)
IndexConnection.FetchVectors fetches vectors by ID from a Pinecone Index.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- ids: The unique IDs of the vectors to fetch.
Returns a pointer to any fetched vectors or an error if the request fails.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } res, err := idxConnection.FetchVectors(ctx, []string{"abc-1"}) if err != nil { log.Fatalf("Failed to fetch vectors, error: %+v", err) } if len(res.Vectors) != 0 { fmt.Println(res) } else { fmt.Println("No vectors found") }
func (*IndexConnection) ListImports ¶
func (idx *IndexConnection) ListImports(ctx context.Context, limit *int32, paginationToken *string) (*ListImportsResponse, error)
IndexConnection.ListImports returns information about Import operations. It returns operations in a paginated form, with a pagination token to fetch the next page of results.
Returns a pointer to a ListImportsResponse object or an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- req: A ListImportsRequest object containing pagination and filter options.
Example:
ctx := context.Background() clientParams := NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } limit := int32(10) firstImportPage, err := idxConnection.ListImports(ctx, &limit, nil) if err != nil { log.Fatalf("Failed to list imports: %v", err) } fmt.Printf("First page of imports: %+v", firstImportPage.Imports) paginationToken := firstImportPage.NextPaginationToken nextImportPage, err := idxConnection.ListImports(ctx, &limit, paginationToken) if err != nil { log.Fatalf("Failed to list imports: %v", err) } fmt.Printf("Second page of imports: %+v", nextImportPage.Imports)
func (*IndexConnection) ListNamespaces ¶
func (idx *IndexConnection) ListNamespaces(ctx context.Context, in *ListNamespacesParams) (*ListNamespacesResponse, error)
IndexConnection.DescribeNamespace lists namespaces within a serverless index.
Returns a pointer to a ListNamespacesResponse object or an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A ListNamespacesParams object containing limit and pagination options.
Example:
ctx := context.Background() clientParams := NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } limit := uint32(10) namespaces, err := pc.ListNamespaces(ctx, &pinecone.ListNamespacesParams{ Limit: &limit }) if err != nil { log.Fatalf("Failed to list namespaces for index \"%s\". Error:%s", idx.Name, err) }
func (*IndexConnection) ListVectors ¶
func (idx *IndexConnection) ListVectors(ctx context.Context, in *ListVectorsRequest) (*ListVectorsResponse, error)
IndexConnection.ListVectors lists vectors in a Pinecone index. You can filter vectors by prefix, limit the number of vectors returned, and paginate through results.
Note: ListVectors is only available for Serverless indexes.
Returns a pointer to a ListVectorsResponse object or an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A ListVectorsRequest object with the parameters for the request.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } prefix := "abc" limit := uint32(10) res, err := idxConnection.ListVectors(ctx, &pinecone.ListVectorsRequest{ Prefix: &prefix, Limit: &limit, }) if err != nil { log.Fatalf("Failed to list vectors in index: %s. Error: %s\n", idx.Name, err) } if len(res.VectorIds) == 0 { fmt.Println("No vectors found") } else { fmt.Printf("Found %d vector(s)\n", len(res.VectorIds)) }
func (*IndexConnection) Namespace ¶
func (idx *IndexConnection) Namespace() string
IndexConnection.Namespace allows returning the namespace the instance of IndexConnection is targeting.
func (*IndexConnection) QueryByVectorId ¶
func (idx *IndexConnection) QueryByVectorId(ctx context.Context, in *QueryByVectorIdRequest) (*QueryVectorsResponse, error)
IndexConnection.QueryByVectorId uses a vector ID to query a Pinecone Index and retrieve vectors that are most similar to the provided ID's underlying vector.
Returns a pointer to a QueryVectorsResponse object or an error if the request fails.
Note: QueryByVectorId executes a nearest neighbors search, meaning that unless TopK=1 in the QueryByVectorIdRequest object, it will return 2+ vectors. The vector with a score of 1.0 is the vector with the same ID as the query vector.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A QueryByVectorIdRequest object with the parameters for the request.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } vectorId := "abc-1" topK := uint32(10) res, err := idxConnection.QueryByVectorId(ctx, &pinecone.QueryByVectorIdRequest{ VectorId: vectorId, TopK: topK, // number of vectors you want returned IncludeValues: true, IncludeMetadata: true, }) if err != nil { log.Fatalf("Error encountered when querying by vector ID `%s`. Error: %s", vectorId, err) } else { for _, match := range res.Matches { fmt.Printf("Match vector with ID `%s`, with score %f\n", match.Vector.Id, match.Score) } }
func (*IndexConnection) QueryByVectorValues ¶
func (idx *IndexConnection) QueryByVectorValues(ctx context.Context, in *QueryByVectorValuesRequest) (*QueryVectorsResponse, error)
IndexConnection.QueryByVectorValues queries a Pinecone Index for vectors that are most similar to a provided query vector.
Returns a pointer to a QueryVectorsResponse object or an error if the request fails.
Note: To issue a hybrid query with both dense and sparse values, your index's similarity metric must be dot-product.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A QueryByVectorValuesRequest object with the parameters for the request.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } queryVector := []float32{1.0, 2.0} topK := uint32(10) metadataMap := map[string]interface{}{ "genre": "classical", } MetadataFilter, err := structpb.NewStruct(metadataMap) if err != nil { log.Fatalf("Failed to create metadata map. Error: %v", err) } sparseValues := pinecone.SparseValues{ Indices: []uint32{0, 1}, Values: []float32{1.0, 2.0}, } res, err := idxConnection.QueryByVectorValues(ctx, &pinecone.QueryByVectorValuesRequest{ Vector: queryVector, TopK: topK, // number of vectors to be returned MetadataFilter: MetadataFilter, SparseValues: &sparseValues, IncludeValues: true, IncludeMetadata: true, }) if err != nil { log.Fatalf("Error encountered when querying by vector: %v", err) } else { for _, match := range res.Matches { fmt.Printf("Match vector `%s`, with score %f\n", match.Vector.Id, match.Score) } }
func (*IndexConnection) SearchRecords ¶
func (idx *IndexConnection) SearchRecords(ctx context.Context, in *SearchRecordsRequest) (*SearchRecordsResponse, error)
IndexConnection.SearchRecords converts a query to a vector embedding and then searches a namespace in an integrated index. You can optionally provide a reranking operation as part of the search.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: The IntegratedRecord objects to upsert.
Returns an error if the request fails.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "my-namespace"}) records := []*IntegratedRecord{ { "_id": "rec1", "chunk_text": "Apple's first product, the Apple I, was released in 1976 and was hand-built by co-founder Steve Wozniak.", "category": "product", }, { "_id": "rec2", "chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.", "category": "nutrition", }, { "_id": "rec3", "chunk_text": "Apples originated in Central Asia and have been cultivated for thousands of years, with over 7,500 varieties available today.", "category": "cultivation", }, { "_id": "rec4", "chunk_text": "In 2001, Apple released the iPod, which transformed the music industry by making portable music widely accessible.", "category": "product", }, { "_id": "rec5", "chunk_text": "Apple went public in 1980, making history with one of the largest IPOs at that time.", "category": "milestone", }, { "_id": "rec6", "chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.", "category": "nutrition", }, { "_id": "rec7", "chunk_text": "Known for its design-forward products, Apple's branding and market strategy have greatly influenced the technology sector and popularized minimalist design worldwide.", "category": "influence", }, { "_id": "rec8", "chunk_text": "The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes.", "category": "nutrition", }, } err = idxConnection.UpsertRecords(ctx, records) if err != nil { log.Fatalf("Failed to upsert vectors. Error: %v", err) } res, err := idxConnection.SearchRecords(ctx, &SearchRecordsRequest{ Query: SearchRecordsQuery{ TopK: 5, Inputs: &map[string]interface{}{ "text": "Disease prevention", }, }, }) if err != nil { log.Fatalf("Failed to search records: %v", err) } fmt.Printf("Search results: %+v\n", res)
func (*IndexConnection) StartImport ¶
func (idx *IndexConnection) StartImport(ctx context.Context, uri string, integrationId *string, errorMode *ImportErrorMode) (*StartImportResponse, error)
IndexConnection.StartImport imports data from a storage provider into an Index. The uri parameter must start with the scheme of a supported storage provider (e.g. "s3://"). For buckets that are not publicly readable, you will also need to separately configure a storage integration and pass the integration id.
Returns a pointer to a StartImportResponse object with the Import ID or an error if the request fails.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- uri: The URI of the data to import. The URI must start with the scheme of a supported storage provider.
- integrationId: If your bucket requires authentication to access, you need to pass the id of your storage integration using this property. Pass nil if not required.
- errorMode: If set to "continue", the import operation will continue even if some records fail to import. Pass "abort" to stop the import operation if any records fail. Will default to "continue" if nil is passed.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } uri := "s3://BUCKET_NAME/PATH/TO/DIR" errorMode := "continue" // or "abort" importRes, err := idxConnection.StartImport(ctx, uri, nil, (*pinecone.ImportErrorMode)(&errorMode)) if err != nil { log.Fatalf("Failed to start import: %v", err) } fmt.Printf("Import started with ID: %s", importRes.Id)
func (*IndexConnection) UpdateVector ¶
func (idx *IndexConnection) UpdateVector(ctx context.Context, in *UpdateVectorRequest) error
IndexConnection.UpdateVector updates a vector in a Pinecone Index by ID.
Returns an error if the request fails, returns nil otherwise.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: An UpdateVectorRequest object with the parameters for the request.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } id := "abc-1" err = idxConnection.UpdateVector(ctx, &pinecone.UpdateVectorRequest{ Id: id, Values: []float32{7.0, 8.0}, }) if err != nil { log.Fatalf("Failed to update vector with ID %s. Error: %s", id, err) }
func (*IndexConnection) UpsertRecords ¶
func (idx *IndexConnection) UpsertRecords(ctx context.Context, records []*IntegratedRecord) error
IndexConnection.UpsertRecords upserts records into an integrated Pinecone Index.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: The IntegratedRecord objects to upsert.
Returns an error if the request fails.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "my-namespace"}) records := []*IntegratedRecord{ { "_id": "rec1", "chunk_text": "Apple's first product, the Apple I, was released in 1976 and was hand-built by co-founder Steve Wozniak.", "category": "product", }, { "_id": "rec2", "chunk_text": "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.", "category": "nutrition", }, { "_id": "rec3", "chunk_text": "Apples originated in Central Asia and have been cultivated for thousands of years, with over 7,500 varieties available today.", "category": "cultivation", }, { "_id": "rec4", "chunk_text": "In 2001, Apple released the iPod, which transformed the music industry by making portable music widely accessible.", "category": "product", }, { "_id": "rec5", "chunk_text": "Apple went public in 1980, making history with one of the largest IPOs at that time.", "category": "milestone", }, { "_id": "rec6", "chunk_text": "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.", "category": "nutrition", }, { "_id": "rec7", "chunk_text": "Known for its design-forward products, Apple's branding and market strategy have greatly influenced the technology sector and popularized minimalist design worldwide.", "category": "influence", }, { "_id": "rec8", "chunk_text": "The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes.", "category": "nutrition", }, } err = idxConnection.UpsertRecords(ctx, &records) if err != nil { log.Fatalf("Failed to upsert vectors. Error: %v", err) } else { log.Fatalf("Successfully upserted %d vector(s)!\n", count) }
func (*IndexConnection) UpsertVectors ¶
IndexConnection.UpsertVectors upserts vectors into a Pinecone Index.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: The vectors to upsert.
Returns the number of vectors upserted or an error if the request fails.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) if err != nil { log.Fatalf("Failed to create IndexConnection for Host: %v. Error: %v", idx.Host, err) } metadataMap := map[string]interface{}{ "genre": "classical", } metadata, err := structpb.NewStruct(metadataMap) if err != nil { log.Fatalf("Failed to create metadata map. Error: %v", err) } denseValues := []float32{1.0, 2.0} sparseValues := pinecone.SparseValues{ Indices: []uint32{0, 1}, Values: []float32{1.0, 2.0}, } vectors := []*pinecone.Vector{ { Id: "abc-1", Values: &denseValues, Metadata: metadata, SparseValues: &sparseValues, }, } count, err := idxConnection.UpsertVectors(ctx, vectors) if err != nil { log.Fatalf("Failed to upsert vectors. Error: %v", err) } else { log.Fatalf("Successfully upserted %d vector(s)!\n", count) }
func (*IndexConnection) WithNamespace ¶
func (idx *IndexConnection) WithNamespace(namespace string) *IndexConnection
IndexConnection.WithNamespace creates a new copy of IndexConnection that targets a new namespace within that index while sharing the underlying gRPC connection. This is useful for performing operations across namespaces in an index without re-creating the index connection.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } idx, err := pc.DescribeIndex(ctx, "your-index-name") if err != nil { log.Fatalf("Failed to describe index \"%s\". Error:%s", idx.Name, err) } idxConnNs1, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "namespace1"}) if err != nil { log.Fatalf("Failed to create IndexConnection: %v", err) } metadataMap := map[string]interface{}{ "genre": "classical", } metadata, err := structpb.NewStruct(metadataMap) if err != nil { log.Fatalf("Failed to create metadata map. Error: %v", err) } values := []float32{1.0, 2.0} vectors := []*pinecone.Vector{ { Id: "abc-1", Values: &values, Metadata: metadata, }, } _, err = idxConnNs1.UpsertVectors(ctx, vectors) if err != nil { log.Fatalf("Failed to upsert vectors in %s. Error: %v", idxConnNs1.Namespace, err) } idxConnNs2 := idxConnNs1.WithNamespace("namespace2") _, err = idxConnNs2.UpsertVectors(ctx, vectors) if err != nil { log.Fatalf("Failed to upsert vectors in %s. Error: %v", idxConnNs2.Namespace, err) }
type IndexEmbed ¶
type IndexEmbed struct { Model string `json:"model"` Dimension *int32 `json:"dimension,omitempty"` Metric *IndexMetric `json:"metric,omitempty"` VectorType *string `json:"vector_type,omitempty"` FieldMap *map[string]interface{} `json:"field_map,omitempty"` ReadParameters *map[string]interface{} `json:"read_parameters,omitempty"` WriteParameters *map[string]interface{} `json:"write_parameters,omitempty"` }
IndexEmbed represents the embedding model configured for an index, including document fields mapped to embedding inputs.
Fields:
- Model: The name of the embedding model used to create the index (e.g., "multilingual-e5-large").
- Dimension: The dimension of the embedding model, specifying the size of the output vector.
- Metric: The distance metric used by the embedding model. If the 'vector_type' is 'sparse', the metric must be 'dotproduct'. If the `vector_type` is `dense`, the metric defaults to 'cosine'.
- VectorType: The index vector type associated with the model. If 'dense', the vector dimension must be specified. If 'sparse', the vector dimension will be nil.
- FieldMap: Identifies the name of the text field from your document model that is embedded.
- ReadParameters: The read parameters for the embedding model.
- WriteParameters: The write parameters for the embedding model.
type IndexMetric ¶
type IndexMetric string
IndexMetric is the similarity metric to be used by similarity search against a Pinecone Index.
const ( Cosine IndexMetric = "cosine" // Default distance metric, ideal for textual data Dotproduct IndexMetric = "dotproduct" // Ideal for hybrid search Euclidean IndexMetric = "euclidean" // Ideal for distance-based data (e.g. lat/long points) )
type IndexSpec ¶
type IndexSpec struct { Pod *PodSpec `json:"pod,omitempty"` Serverless *ServerlessSpec `json:"serverless,omitempty"` }
IndexSpec is the infrastructure specification (pods vs serverless) of a Pinecone Index.
type IndexStatus ¶
type IndexStatus struct { Ready bool `json:"ready"` State IndexStatusState `json:"state"` }
IndexStatus is the status of a Pinecone Index.
type IndexStatusState ¶
type IndexStatusState string
IndexStatusState is the state of a Pinecone Index.
const ( InitializationFailed IndexStatusState = "InitializationFailed" Initializing IndexStatusState = "Initializing" Ready IndexStatusState = "Ready" ScalingDown IndexStatusState = "ScalingDown" ScalingDownPodSize IndexStatusState = "ScalingDownPodSize" ScalingUp IndexStatusState = "ScalingUp" ScalingUpPodSize IndexStatusState = "ScalingUpPodSize" Terminating IndexStatusState = "Terminating" )
type InferenceService ¶
type InferenceService struct {
// contains filtered or unexported fields
}
InferenceService is a struct which exposes methods for interacting with the Pinecone Inference API. InferenceService can be accessed via the Client object through the Client.Inference namespace.
func (*InferenceService) DescribeModel ¶
InferenceService.DescribeModel gets a description of a model hosted by Pinecone.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- modelName: The name of the model to retrieve information about.
Returns a pointer to a ModelInfo object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } model, err := pc.Inference.DescribeModel(ctx, "multilingual-e5-large") if err != nil { log.Fatalf("Failed to get model: %v", err) } fmt.Printf("Model (multilingual-e5-large): %+v\n", model)
func (*InferenceService) Embed ¶
func (i *InferenceService) Embed(ctx context.Context, in *EmbedRequest) (*EmbedResponse, error)
InferenceService.Embed generates embeddings for a list of inputs using the specified model and (optional) parameters.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to an EmbedRequest object that contains the model to use for embedding generation, the list of input strings to generate embeddings for, and any additional parameters to use for generation.
Returns a pointer to an [EmbeddingsList] object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } 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!") } in := &pinecone.EmbedRequest{ Model: "multilingual-e5-large", TextInputs: []string{"Who created the first computer?"}, Parameters: pinecone.EmbedParameters{ InputType: "passage", Truncate: "END", }, } res, err := pc.Inference.Embed(ctx, in) if err != nil { log.Fatalf("Failed to embed: %v", err) } else { fmt.Printf("Successfull generated embeddings: %+v", res) }
func (*InferenceService) ListModels ¶
func (i *InferenceService) ListModels(ctx context.Context, in *ListModelsParams) (*ModelInfoList, error)
InferenceService.ListModels lists all available models hosted by Pinecone. You can filter results using ListModelsParams.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: The name of the model to retrieve information about.
Returns a pointer to a ModelInfoList object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } embed := "embed" embedModels, err := pc.Inference.ListModels(ctx, &pinecone.ListModelsParams{ Type: &embed }) if err != nil { log.Fatalf("Failed to list models: %v", err) } fmt.Printf("Embed Models: %+v\n", embedModels)
func (*InferenceService) Rerank ¶
func (i *InferenceService) Rerank(ctx context.Context, in *RerankRequest) (*RerankResponse, error)
InferenceService.Rerank reranks documents with associated relevance scores that represent the relevance of each Document to the provided query using the specified model.
Parameters:
- ctx: A context.Context object controls the request's lifetime, allowing for the request to be canceled or to timeout according to the context's deadline.
- in: A pointer to a RerankRequest object that contains the model, query, and documents to use for reranking.
Returns a pointer to a RerankResponse object or an error.
Example:
ctx := context.Background() clientParams := pinecone.NewClientParams{ ApiKey: "YOUR_API_KEY", SourceTag: "your_source_identifier", // optional } pc, err := pinecone.NewClient(clientParams) if err != nil { log.Fatalf("Failed to create Client: %v", err) } rerankModel := "bge-reranker-v2-m3" topN := 2 retunDocuments := true documents := []pinecone.Document{ {"id": "doc1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."}, {"id": "doc2", "text": "Many people enjoy eating apples as a healthy snack."}, {"id": "doc3", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."}, {"id": "doc4", "text": "An apple a day keeps the doctor away, as the saying goes."}, } ranking, err := pc.Inference.Rerank(ctx, &pinecone.RerankRequest{ Model: rerankModel, Query: "i love to eat apples", ReturnDocuments: &retunDocuments, TopN: &topN, RankFields: &[]string{"text"}, Documents: documents, }) if err != nil { log.Fatalf("Failed to rerank: %v", err) } fmt.Printf("Rerank result: %+v\n", ranking)
type IntegratedRecord ¶
type IntegratedRecord map[string]interface{}
type ListBackupsParams ¶
type ListBackupsParams struct { IndexName *string `json:"index_name,omitempty"` Limit *int `json:"limit,omitempty"` PaginationToken *string `json:"pagination_token,omitempty"` }
ListBackupsParams contains the query parameters used when listing backups.
Fields:
- IndexName: Optional filter to list backups for a specific index. Otherwise, all backups in the project will be listed.
- Limit: Optional maximum number of backups to return.
- PaginationToken: Optional token to retrieve the next page of results. Will be nil if there are no more results.
type ListImportsRequest ¶
ListImportsRequest holds the parameters for the IndexConnection.ListImports method.
Fields:
- Limit: The maximum number of imports to return.
- PaginationToken: The token to retrieve the next page of imports, if available.
type ListImportsResponse ¶
type ListImportsResponse struct { Imports []*Import `json:"imports,omitempty"` NextPaginationToken *string `json:"next_pagination_token,omitempty"` }
ListImportsResponse holds the result of listing Import objects.
Fields:
- Imports: The list of Import objects returned.
- NextPaginationToken: The token for paginating through results, if more imports are available.
type ListModelsParams ¶
ListModelsParams holds the parameters for filtering model results when calling InferenceService.ListModels.
Fields:
- Type: (Optional) The type of model to filter by. Can be either "embed" or "rerank".
- VectorType: (Optional) The vector type of the model to filter by. Can be either "dense" or "sparse". Only relevant if Type is "embed".
type ListNamespacesParams ¶
ListNamespacesParams holds the parameters for the IndexConnection.ListNamespaces method.
Fields:
- PaginationToken: The token to retrieve the next page of namespaces, if available.
- Limit: The maximum number of namespaces to return.
type ListNamespacesResponse ¶
type ListNamespacesResponse struct { Namespaces []*NamespaceDescription Pagination *Pagination }
ListNamespacesResponse is returned by the IndexConnection.ListNamespaces method.
Fields:
- Namespaces: A slice of NamespaceDescription objects.
- Pagination: The Pagination object for paginating results.
type ListRestoreJobsParams ¶
type ListRestoreJobsParams struct { Limit *int `json:"limit,omitempty"` PaginationToken *string `json:"pagination_token,omitempty"` }
ListRestoreJobsParams contains the query parameters used when listing restore jobs.
Fields:
- Limit: Optional maximum number of restore jobs to return.
- PaginationToken: Optional token to retrieve the next page of results. Will be nil if there are no more results.
type ListVectorsRequest ¶
ListVectorsRequest holds the parameters passed into the IndexConnection.ListVectors method.
Fields:
- Prefix: (Optional) The prefix by which to filter. If unspecified, an empty string will be used which will list all vector ids in the namespace
- Limit: (Optional) The maximum number of vectors to return. If unspecified, the server will use a default value.
- PaginationToken: (Optional) The token for paginating through results.
type ListVectorsResponse ¶
type ListVectorsResponse struct { VectorIds []*string `json:"vector_ids,omitempty"` Usage *Usage `json:"usage,omitempty"` NextPaginationToken *string `json:"next_pagination_token,omitempty"` Namespace string `json:"namespace"` }
ListVectorsResponse is returned by the IndexConnection.ListVectors method.
Fields:
- VectorIds: The unique IDs of the returned vectors.
- Usage: The usage information for the request.
- NextPaginationToken: The token for paginating through results.
- Namespace: The namespace vector ids are listed from.
type Metadata ¶
Metadata represents optional, additional information that can be attached to, or updated for, a vector in a Pinecone Index.
type MetadataFilter ¶
MetadataFilter represents the metadata filters attached to a Pinecone request. These optional metadata filters are applied to query and deletion requests.
type ModelInfo ¶
type ModelInfo struct { DefaultDimension *int32 `json:"default_dimension,omitempty"` MaxBatchSize *int32 `json:"max_batch_size,omitempty"` MaxSequenceLength *int32 `json:"max_sequence_length,omitempty"` Modality *string `json:"modality,omitempty"` Model string `json:"model"` ProviderName *string `json:"provider_name,omitempty"` ShortDescription string `json:"short_description"` SupportedDimensions *[]int32 `json:"supported_dimensions,omitempty"` SupportedMetrics *[]IndexMetric `json:"supported_metrics,omitempty"` SupportedParameters *[]SupportedParameter `json:"supported_parameters,omitempty"` Type string `json:"type"` VectorType *string `json:"vector_type,omitempty"` }
ModelInfo represents the model configuration include model type, supported parameters, and other model details.
Fields:
- DefaultDimension: The default embedding model dimension (applies to dense embedding models only).
- MaxBatchSize: The maximum batch size (number of sequences) supported by the model.
- MaxSequenceLength: The maximum tokens per sequence supported by the model.
- Modality: The modality of the model (e.g. "text").
- Model: The name of the model.
- ProviderName: The name of the provider of the model. (e.g. "Pinecone", "NVIDIA").
- ShortDescription: A summary of the model.
- SupportedDimensions: The list of supported dimensions for the model (applies to dense embedding models only).
- SupportedMetrics: The distance metrics supported by the model for similarity search (e.g. "cosine", "dotproduct", "euclidean").
- SupportedParameters: A list of parameters supported by the model, including parameter value constraints.
- Type: The type of model (e.g. "embed" or "rerank").
- VectorType: Whether the embedding model produces "dense" or "sparse" embeddings.
type ModelInfoList ¶
type ModelInfoList struct {
Models *[]ModelInfo `json:"models,omitempty"`
}
ModelInfoList represents a list of ModelInfo objects describing the models hosted by Pinecone.
Fields:
- Models: A slice of ModelInfo objects.
type NamespaceDescription ¶
type NamespaceDescription struct { Name string `json:"name"` RecordCount uint64 `json:"record_count"` }
NamespaceDescription is a description of a Pinecone [namespace].
[namespace]: https://docs.pinecone.io/guides/indexes/use-namespaces Fields:
- Name: The name of the namespace.
- RecordCount: The number of records in the namespace.
type NamespaceSummary ¶
type NamespaceSummary struct {
VectorCount uint32 `json:"vector_count"`
}
NamespaceSummary is a summary of stats for a Pinecone [namespace].
[namespace]: https://docs.pinecone.io/guides/indexes/use-namespaces Fields:
- VectorCount: The number of vectors in the namespace.
type NewAdminClientParams ¶ added in v4.1.0
type NewAdminClientParams struct { // The OAuth client ID used for authentication. ClientId string // The OAuth client secret used for authentication. ClientSecret string // The OAuth access token used for authentication. AccessToken string // The host URL of the Pinecone API. If not provided, the default value is "https://api.pinecone.io". Host string // (Optional) Additional headers to include in the request. Headers *map[string]string // (Optional)The HTTP client to use for the request. RestClient *http.Client // (Optional)The source tag to include in the request. SourceTag *string }
NewAdminClientParams contains parameters used to configure the AdminClient. You must provide either a client ID and secret, or an access token, either directly or via environment variables (PINECONE_CLIENT_ID, PINECONE_CLIENT_SECRET, PINECONE_ACCESS_TOKEN).
type NewClientBaseParams ¶
type NewClientBaseParams struct { Headers map[string]string Host string RestClient *http.Client SourceTag string }
NewClientBaseParams holds the parameters for creating a new Client instance while passing custom authentication headers. If there is no API key or authentication provided through Headers, API calls will fail.
Fields:
- Headers: (Optional) A map of HTTP headers to include in each API request. "Authorization" and "X-Project-Id" headers are required if authenticating using a JWT.
- Host: (Optional) The host URL of the Pinecone API. If not provided, the default value is "https://api.pinecone.io".
- RestClient: (Optional) An *http.Client object to use for communication with the Pinecone API.
- SourceTag: (Optional) A string used to help Pinecone attribute API activity.
See Client for code example.
type NewClientParams ¶
type NewClientParams struct { ApiKey string // required - provide through NewClientParams or environment variable PINECONE_API_KEY Headers map[string]string // optional Host string // optional RestClient *http.Client // optional SourceTag string // optional }
NewClientParams holds the parameters for creating a new Client instance while authenticating via an API key.
Fields:
- ApiKey: (Required) The API key used to authenticate with the Pinecone API. This value must be passed by the user unless it is set as an environment variable ("PINECONE_API_KEY").
- Headers: (Optional) An optional map of HTTP headers to include in each API request.
- Host: (Optional) The host URL of the Pinecone API. If not provided, the default value is "https://api.pinecone.io".
- RestClient: An optional HTTP client to use for communication with the Pinecone API.
- SourceTag: An optional string used to help Pinecone attribute API activity.
See Client for code example.
type NewIndexConnParams ¶
type NewIndexConnParams struct { Host string // required - obtained through DescribeIndex or ListIndexes Namespace string // optional - if not provided the default namespace of "__default__" will be used AdditionalMetadata map[string]string // optional }
NewIndexConnParams holds the parameters for creating an IndexConnection to a Pinecone index.
Fields:
- Host: (Required) The host URL of the Pinecone index. To find your host url use the Client.DescribeIndex or Client.ListIndexes methods. Alternatively, the host is displayed in the Pinecone web console.
- Namespace: (Optional) The index namespace to use for operations. If not provided, the default namespace of "" will be used.
- AdditionalMetadata: (Optional) Metadata to be sent with each RPC request.
See Client.Index for code example.
type Organization ¶ added in v4.1.0
type Organization struct { // The name of the organization. Name string `json:"name"` // The unique ID of the organization. Id string `json:"id"` // The date and time when the organization was created. CreatedAt time.Time `json:"created_at"` // The current payment status of the organization. PaymentStatus string `json:"payment_status"` // The current plan the organization is on. Plan string `json:"plan"` // The support tier of the organization. SupportTier string `json:"support_tier"` }
Organization represents the details of an organization.
type OrganizationClient ¶ added in v4.1.0
type OrganizationClient interface { // List all organizations available to the authenticated service account. List(ctx context.Context) ([]*Organization, error) // Describe an organization by ID. Describe(ctx context.Context, organizationId string) (*Organization, error) // Update an existing organization by ID. Update(ctx context.Context, organizationId string, in *UpdateOrganizationParams) (*Organization, error) // Delete an organization by ID. All projects within the organization must be deleted first. Delete(ctx context.Context, organizationId string) error }
OrganizationClient provides an interface for managing organizations.
type Pagination ¶
type Pagination struct {
Next string `json:"next"`
}
Pagination represents the pagination information for a list of resources.
type PineconeError ¶
func (*PineconeError) Error ¶
func (pe *PineconeError) Error() string
type PodSpec ¶
type PodSpec struct { Environment string `json:"environment"` PodType string `json:"pod_type"` PodCount int `json:"pod_count"` Replicas int32 `json:"replicas"` ShardCount int32 `json:"shard_count"` SourceCollection *string `json:"source_collection,omitempty"` MetadataConfig *PodSpecMetadataConfig `json:"metadata_config,omitempty"` }
PodSpec is the infrastructure specification of a pod-based Pinecone Index. Only available for pod-based Indexes.
Fields:
- Environment: The environment where the index is hosted.
- PodType: The pod type used for the index. Must be one of "s1", "p1", or "p2" followed by ".x1", ".x2", ".x4", or ".x8".
- PodCount: The number of pods used for the index. Should equal `shards` × `replicas`.
- Replicas: The number of replicas. Replicas duplicate the index. They provide higher availability and throughput.
- ShardCount: The number of shards. Shards split your data across multiple pods so you can fit more data into an index.
- SourceCollection: The name of the Collection used as a source for the index.
- MetadataConfig: Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed.
type PodSpecMetadataConfig ¶
type PodSpecMetadataConfig struct {
Indexed *[]string `json:"indexed,omitempty"`
}
PodSpecMetadataConfig represents the metadata fields to be indexed when a Pinecone Index is created.
type Project ¶ added in v4.1.0
type Project struct { // The name of the project. Name string `json:"name"` // The unique ID of the project. Id string `json:"id"` // The unique ID of the organization that the project belongs to. OrganizationId string `json:"organization_id"` // The date and time when the project was created. CreatedAt *time.Time `json:"created_at,omitempty"` // Whether to force encryption with a customer-managed encryption key (CMEK). ForceEncryptionWithCmek bool `json:"force_encryption_with_cmek"` // The maximum number of Pods that can be created in the project. MaxPods int `json:"max_pods"` }
Project represents the details of a project.
type ProjectClient ¶ added in v4.1.0
type ProjectClient interface { // Create a new project. Create(ctx context.Context, in *CreateProjectParams) (*Project, error) // Update an existing project by ID. Update(ctx context.Context, projectId string, in *UpdateProjectParams) (*Project, error) // List all projects available to the authenticated service account. List(ctx context.Context) ([]*Project, error) // Describe an existing project by ID. Describe(ctx context.Context, projectId string) (*Project, error) // Delete a project by ID. Delete(ctx context.Context, projectId string) error }
ProjectClient provides an interface for managing Pinecone projects.
type QueryByVectorIdRequest ¶
type QueryByVectorIdRequest struct { VectorId string TopK uint32 MetadataFilter *MetadataFilter IncludeValues bool IncludeMetadata bool SparseValues *SparseValues }
QueryByVectorIdRequest holds the parameters for the IndexConnection.QueryByVectorId method.
Fields:
- VectorId: (Required) The unique ID of the vector used to find similar vectors.
- TopK: (Required) The number of vectors to return.
- MetadataFilter: (Optional) The filter to apply to your query.
- IncludeValues: (Optional) Whether to include the values of the vectors in the response.
- IncludeMetadata: (Optional) Whether to include the metadata associated with the vectors in the response.
- SparseValues: (Optional) The sparse values of the query vector, if applicable.
type QueryByVectorValuesRequest ¶
type QueryByVectorValuesRequest struct { Vector []float32 TopK uint32 MetadataFilter *MetadataFilter IncludeValues bool IncludeMetadata bool SparseValues *SparseValues }
QueryByVectorValuesRequest holds the parameters for the IndexConnection.QueryByVectorValues method.
Fields:
- Vector: (Required) The query vector used to find similar vectors.
- TopK: (Required) The number of vectors to return.
- MetadataFilter: (Optional) The filter to apply to your query.
- IncludeValues: (Optional) Whether to include the values of the vectors in the response.
- IncludeMetadata: (Optional) Whether to include the metadata associated with the vectors in the response.
- SparseValues: (Optional) The sparse values of the query vector, if applicable.
type QueryVectorsResponse ¶
type QueryVectorsResponse struct { Matches []*ScoredVector `json:"matches,omitempty"` Usage *Usage `json:"usage,omitempty"` Namespace string `json:"namespace"` }
QueryVectorsResponse is returned by the IndexConnection.QueryByVectorValues method.
Fields:
- Matches: The vectors that are most similar to the query vector.
- Usage: The usage information for the request.
- Namespace: The namespace from which the vectors were queried.
type RankedDocument ¶
type RankedDocument struct { Document *Document `json:"document,omitempty"` Index int `json:"index"` Score float32 `json:"score"` }
RankedDocument represents a ranked document with a relevance score and an index position.
Fields:
- Document: The Document.
- Index: The index position of the Document from the original request. This can be used to locate the position of the document relative to others described in the request.
- Score: The relevance score of the Document indicating how closely it matches the query.
type RerankRequest ¶
type RerankRequest struct { Model string Query string Documents []Document RankFields *[]string ReturnDocuments *bool TopN *int Parameters *map[string]interface{} }
RerankRequest holds the parameters for calling InferenceService.Rerank and reranking documents by a specified query and model.
Fields:
- Model: (Required) The model to use for reranking.
- Query: (Required) The query to rerank Documents against.
- Documents: (Required) A list of Document objects to be reranked. The default is "text", but you can specify this behavior with [RerankRequest.RankFields].
- RankFields: (Optional) The fields to rank the Documents by. If not provided, the default is "text".
- ReturnDocuments: (Optional) Whether to include Documents in the response. Defaults to true.
- TopN: (Optional) How many Documents to return. Defaults to the length of input Documents.
- Parameters: (Optional) Additional model-specific parameters for the reranker
type RerankResponse ¶
type RerankResponse struct { Data []RankedDocument `json:"data,omitempty"` Model string `json:"model"` Usage RerankUsage `json:"usage"` }
RerankResponse is the result of a reranking operation.
Fields:
- Data: A list of RankedDocument objects which have been reranked. The RankedDocuments are sorted in order of relevance, with the first being the most relevant.
- Model: The model used to rerank documents.
- Usage: Usage statistics ([Rerank Units]) for the reranking operation.
type RerankUsage ¶
type RerankUsage struct {
RerankUnits *int `json:"rerank_units,omitempty"`
}
RerankUsage is the usage stats (Rerank Units) for a reranking request.
type RestoreJob ¶
type RestoreJob struct { BackupId string `json:"backup_id"` CompletedAt *time.Time `json:"completed_at,omitempty"` CreatedAt time.Time `json:"created_at"` PercentComplete *float32 `json:"percent_complete,omitempty"` RestoreJobId string `json:"restore_job_id"` Status string `json:"status"` TargetIndexId string `json:"target_index_id"` TargetIndexName string `json:"target_index_name"` }
RestoreJob describes the status of a restore job.
Fields:
- BackupId: Backup used for the restore.
- CompletedAt: Timestamp when the restore job finished.
- CreatedAt: Timestamp when the restore job started.
- PercentComplete: The progress made by the restore job out of 100.
- RestoreJobId: Unique identifier for the restore job.
- Status: Status of the restore job.
- TargetIndexId: ID of the index.
- TargetIndexName: Name of the index into which data is being restored.
type RestoreJobList ¶
type RestoreJobList struct { Data []*RestoreJob `json:"data"` Pagination *Pagination `json:"pagination,omitempty"` }
RestoreJobList contains a paginated list of restore jobs.
Fields:
- Data: A list of RestoreJob records.
- Pagination: Pagination token for fetching the next page of results.
type ScoredVector ¶
ScoredVector is a vector with an associated similarity score calculated according to the distance metric of the Index.
type SearchRecordsQuery ¶
type SearchRecordsQuery struct { TopK int32 `json:"top_k"` Filter *map[string]interface{} `json:"filter,omitempty"` Id *string `json:"id,omitempty"` Inputs *map[string]interface{} `json:"inputs,omitempty"` Vector *SearchRecordsVector `json:"vector,omitempty"` }
SearchRecordsQuery represents the query parameters for searching records.
Fields:
- TopK: The number of results to return for each search.
- Filter: The filter to apply.
- Id: The unique ID of the vector to be used as a query vector.
- Inputs: Additional input parameters for the query.
- Vector: The vector representation of the query.
type SearchRecordsRequest ¶
type SearchRecordsRequest struct { Query SearchRecordsQuery `json:"query"` Fields *[]string `json:"fields,omitempty"` Rerank *SearchRecordsRerank `json:"rerank,omitempty"` }
SearchRecordsRequest represents a search request for records in a specific namespace.
Fields:
- Query: The query inputs to search with.
- Fields: The fields to return in the search results.
- Rerank: Parameters for reranking the initial search results.
type SearchRecordsRerank ¶
type SearchRecordsRerank struct { Model string `json:"model"` RankFields []string `json:"rank_fields"` Parameters *map[string]interface{} `json:"parameters,omitempty"` Query *string `json:"query,omitempty"` TopN *int32 `json:"top_n,omitempty"` }
SearchRecordsRerank represents the parameters for reranking search results.
Fields:
- Model: The name of the [reranking model](https://docs.pinecone.io/guides/inference/understanding-inference#reranking-models) to use.
- RankFields: The field(s) to consider for reranking. Defaults to `["text"]`. The number of fields supported is [model-specific](https://docs.pinecone.io/guides/inference/understanding-inference#reranking-models).
- Parameters: Additional model-specific parameters. Refer to the [model guide](https://docs.pinecone.io/guides/inference/understanding-inference#reranking-models) for available model parameters.
- Query: The query to rerank documents against. If a specific rerank query is specified, it overwrites the query input that was provided at the top level.
- TopN: The number of top results to return after reranking. Defaults to top_k.
type SearchRecordsResponse ¶
type SearchRecordsResponse struct { Result struct { Hits []Hit `json:"hits"` } `json:"result"` Usage SearchUsage `json:"usage"` }
SearchRecordsResponse represents the response of a records search.
Fields:
- Result: The result object containing the Hit responses for the search.
- Usage: The resource usage details for the search operation.
type SearchRecordsVector ¶
type SearchRecordsVector struct { SparseIndices *[]int32 `json:"sparse_indices,omitempty"` SparseValues *[]float32 `json:"sparse_values,omitempty"` Values *[]float32 `json:"values,omitempty"` }
SearchRecordsVector represents the vector data used in a search request.
Fields:
- SparseIndices: The sparse embedding indices.
- SparseValues: The sparse embedding values.
- Values: The dense vector data included in the request.
type SearchUsage ¶
type SearchUsage struct { ReadUnits int32 `json:"read_units"` EmbedTotalTokens *int32 `json:"embed_total_tokens,omitempty"` RerankUnits *int32 `json:"rerank_units,omitempty"` }
SearchUsage represents the resource usage details of a search operation.
Fields:
- ReadUnits: The number of read units consumed by this operation.
- EmbedTotalTokens: The number of embedding tokens consumed by this operation.
- RerankUnits: The number of rerank units consumed by this operation.
type ServerlessSpec ¶
type ServerlessSpec struct { Cloud Cloud `json:"cloud"` Region string `json:"region"` SourceCollection *string `json:"source_collection,omitempty"` }
ServerlessSpec is the infrastructure specification of a serverless Pinecone Index. Only available for serverless Indexes.
Fields:
- Cloud: The public cloud provider where the index is hosted.
- Region: The region where the index is hosted.
- SourceCollection: The name of the Collection used as a source for the index.
type SparseEmbedding ¶
type SparseEmbedding struct { VectorType string `json:"vector_type"` SparseValues []float32 `json:"sparse_values"` SparseIndices []int64 `json:"sparse_indices"` SparseTokens *[]string `json:"sparse_tokens,omitempty"` }
SparseEmbedding represents a sparse embedding of the input, where only selected dimensions are populated.
Fields:
- VectorType: A string indicating the type of vector embedding ("sparse").
- SparseValues: A slice of float32 values representing the sparse embedding value.
- SparseIndices: A slice of int64 values representing the embedding indices.
- SparseTokens: The normalized tokens used to create the sparse embedding, if requested.
type SparseValues ¶
type SparseValues struct { Indices []uint32 `json:"indices,omitempty"` Values []float32 `json:"values,omitempty"` }
SparseValues is a sparse vector object, most commonly used for hybrid search.
type StartImportResponse ¶
type StartImportResponse struct {
Id string `json:"id,omitempty"`
}
StartImportResponse holds the response parameters for the IndexConnection.StartImport method.
Fields:
- Id: The ID of the import process that was started.
type SupportedParameter ¶
type SupportedParameter struct { AllowedValues *[]SupportedParameterValue `json:"allowed_values,omitempty"` Default *SupportedParameterValue `json:"default,omitempty"` Max *float32 `json:"max,omitempty"` Min *float32 `json:"min,omitempty"` Parameter string `json:"parameter"` Required bool `json:"required"` Type string `json:"type"` ValueType string `json:"value_type"` }
SupportedParameter describes a parameter supported by the model, including parameter value constraints.
Fields:
- AllowedValues: The allowed parameter values when the type is "one_of".
- Default: The default value for the parameter when a parameter is optional.
- Max: The maximum allowed value (inclusive) when the type is "numeric_range".
- Min: The minimum allowed value (inclusive) when the type is "numeric_range".
- Parameter: The name of the parameter.
- Required: Indicates whether this parameter is required or optional.
- Type: The parameter type e.g. "one_of", "numeric_range", or "any". If the type is "one_of", then "allowed_values" will be set, and the value specified must be one of the allowed values. "one_of" is only compatible with ValueType "string" or "integer". If "numeric_range", then "min" and "max" will be set, then the value specified must adhere to the ValueType and must fall within the `[Min, Max]` range. If "any" then any value is allowed, as long as it adheres to the ValueType.
- ValueType: The type of value the parameter accepts, e.g. "string", "integer", "float", or "boolean".
type SupportedParameterValue ¶
type SupportedParameterValue struct { StringValue *string IntValue *int32 FloatValue *float32 BoolValue *bool }
SupportedParameterValue is a tagged union type representing the value of a SupportedParameter.
Fields:
- StringValue: A string-based value, if the parameter accepts strings.
- IntValue: An integer-based value, if the parameter accepts integers.
- FloatValue: A float-based value, if the parameter accepts floating point numbers.
- BoolValue: A boolean value, if the parameter accepts true/false input.
func (*SupportedParameterValue) UnmarshalJSON ¶
func (spv *SupportedParameterValue) UnmarshalJSON(data []byte) error
type UpdateAPIKeyParams ¶ added in v4.1.0
type UpdateAPIKeyParams struct { // (Optional) A new name for the API key. The name must be 1-80 characters long. If omitted, the name will not be updated. Name *string `json:"name,omitempty"` // (Optional) A new set of roles for the API key. Existing roles will be removed if not included. // Expected values:ProjectEditor, ProjectViewer, ControlPlaneEditor, ControlPlaneViewer, DataPlaneEditor, DataPlaneViewer // If this field is omitted, the roles will not be updated. Roles *[]string `json:"roles,omitempty"` }
UpdateAPIKeyParams contains parameters for updating an existing API key.
type UpdateOrganizationParams ¶ added in v4.1.0
type UpdateOrganizationParams struct { // (Optional) The new name of the organization. Name *string `json:"name"` }
UpdateOrganizationParams contains parameters for updating an existing organization.
type UpdateProjectParams ¶ added in v4.1.0
type UpdateProjectParams struct { // (Optional) The name of the new project. Name *string `json:"name,omitempty"` // (Optional) Whether to force encryption with a customer-managed encryption key (CMEK). // Once enabled, CMEK encryption cannot be disabled. ForceEncryptionWithCmek *bool `json:"force_encryption_with_cmek,omitempty"` // (Optional) The maximum number of Pods that can be created in the project. MaxPods *int `json:"max_pods,omitempty"` }
UpdateProjectParams contains parameters for updating an existing project.
type UpdateVectorRequest ¶
type UpdateVectorRequest struct { Id string Values []float32 SparseValues *SparseValues Metadata *Metadata }
UpdateVectorRequest holds the parameters for the IndexConnection.UpdateVector method.
Fields:
- Id: (Required) The unique ID of the vector to update.
- Values: The values with which you want to update the vector.
- SparseValues: The sparse values with which you want to update the vector.
- Metadata: The metadata with which you want to update the vector.
type Usage ¶
type Usage struct {
ReadUnits uint32 `json:"read_units"`
}
Usage is the usage stats (Read Units) for a Pinecone Index.
type Vector ¶
type Vector struct { Id string `json:"id"` Values *[]float32 `json:"values,omitempty"` SparseValues *SparseValues `json:"sparse_values,omitempty"` Metadata *Metadata `json:"metadata,omitempty"` }
Vector is a dense or sparse vector object with optional metadata.