Documentation
¶
Overview ¶
Package pinecone provides a client for the Pinecone managed vector database.
Index ¶
- func GenerateTestIndexName() string
- func WaitUntilIndexReady(ts *IntegrationTests, ctx context.Context) (bool, error)
- type Client
- func (c *Client) ConfigureIndex(ctx context.Context, name string, in ConfigureIndexParams) (*Index, error)
- func (c *Client) CreateCollection(ctx context.Context, in *CreateCollectionRequest) (*Collection, 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) DeleteCollection(ctx context.Context, collectionName string) error
- func (c *Client) DeleteIndex(ctx context.Context, idxName string) 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) Index(in NewIndexConnParams, dialOpts ...grpc.DialOption) (*IndexConnection, error)
- func (c *Client) ListCollections(ctx context.Context) ([]*Collection, error)
- func (c *Client) ListIndexes(ctx context.Context) ([]*Index, error)
- type Cloud
- type Collection
- type CollectionStatus
- type ConfigureIndexParams
- type CreateCollectionRequest
- type CreatePodIndexRequest
- type CreateServerlessIndexRequest
- type DeletionProtection
- type DescribeIndexStatsResponse
- type Document
- type EmbedParameters
- type EmbedRequest
- type EmbedResponse
- type Embedding
- type FetchVectorsResponse
- 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) 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) FetchVectors(ctx context.Context, ids []string) (*FetchVectorsResponse, error)
- func (idx *IndexConnection) ListImports(ctx context.Context, limit *int32, paginationToken *string) (*ListImportsResponse, error)
- func (idx *IndexConnection) ListVectors(ctx context.Context, in *ListVectorsRequest) (*ListVectorsResponse, error)
- 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) StartImport(ctx context.Context, uri string, integrationId *string, ...) (*StartImportResponse, error)
- func (idx *IndexConnection) UpdateVector(ctx context.Context, in *UpdateVectorRequest) error
- func (idx *IndexConnection) UpsertVectors(ctx context.Context, in []*Vector) (uint32, error)
- type IndexMetric
- type IndexSpec
- type IndexStatus
- type IndexStatusState
- type IndexTags
- type InferenceService
- type IntegrationTests
- type ListImportsRequest
- type ListImportsResponse
- type ListVectorsRequest
- type ListVectorsResponse
- type Metadata
- type MetadataFilter
- type NamespaceSummary
- type NewClientBaseParams
- type NewClientParams
- type NewIndexConnParams
- type PineconeError
- type PodSpec
- type PodSpecMetadataConfig
- type QueryByVectorIdRequest
- type QueryByVectorValuesRequest
- type QueryVectorsResponse
- type RankedDocument
- type RerankRequest
- type RerankResponse
- type RerankUsage
- type ScoredVector
- type ServerlessSpec
- type SparseValues
- type StartImportResponse
- type UpdateVectorRequest
- type Usage
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitUntilIndexReady ¶
func WaitUntilIndexReady(ts *IntegrationTests, ctx context.Context) (bool, error)
Types ¶
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) 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) 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) 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) 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) 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) 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) } }
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.
type CollectionStatus ¶
type CollectionStatus string
CollectionStatus is the status of a Pinecone Collection.
const ( CollectionStatusInitializing CollectionStatus = "Initializing" CollectionStatusReady CollectionStatus = "Ready" CollectionStatusTerminating CollectionStatus = "Terminating" )
type ConfigureIndexParams ¶
type ConfigureIndexParams struct { PodType string Replicas int32 DeletionProtection DeletionProtection Tags IndexTags }
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.
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 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 CreatePodIndexRequest ¶
type CreatePodIndexRequest struct { Name string Dimension int32 Metric IndexMetric DeletionProtection DeletionProtection Environment string PodType string Shards int32 Replicas int32 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'.
- 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.
- DeletionProtection: (Optional) 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.
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 CreateServerlessIndexRequest ¶
type CreateServerlessIndexRequest struct { Name string Dimension int32 Metric IndexMetric DeletionProtection DeletionProtection Cloud Cloud Region string Tags *IndexTags }
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 '-'.
- Dimension: (Required) The dimensionality of the vectors to be inserted in the Index.
- Metric: (Required) The metric used to measure the similarity between vectors ('euclidean', 'cosine', or 'dotproduct').
- DeletionProtection: (Optional) Determines whether deletion protection is "enabled" or "disabled" for the index. When "enabled", the index cannot be deleted. Defaults to "disabled".
- 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.
- Tags: (Optional) A map of tags to associate with the Index.
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 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 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 EmbedParameters ¶
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 *int `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 {
Values *[]float32 `json:"values,omitempty"`
}
Embedding represents the embedding of a single input which is returned after generating embeddings.
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 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"` Dimension int32 `json:"dimension"` Host string `json:"host"` Metric IndexMetric `json:"metric"` DeletionProtection DeletionProtection `json:"deletion_protection,omitempty"` Spec *IndexSpec `json:"spec,omitempty"` Status *IndexStatus `json:"status,omitempty"` Tags *IndexTags `json:"tags,omitempty"` }
Index is a Pinecone Index object. Can be either a pod-based or a serverless Index, depending on the IndexSpec.
type IndexConnection ¶
type IndexConnection struct { Namespace string // contains filtered or unexported fields }
IndexConnection holds the parameters for a Pinecone IndexConnection object. You can instantiate an IndexConnection by calling the Client.Index method with a NewIndexConnParams object.
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", idxConnection.Namespace, 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) 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) 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) 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) 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://your-bucket/your-file.csv" errorMode := "abort" importRes, err := idxConnection.StartImport(ctx, uri, nil, &errorMode) if err != nil { log.Fatalf("Failed to start import: %v", err) } fmt.Printf("import starteed 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) 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) } sparseValues := pinecone.SparseValues{ Indices: []uint32{0, 1}, Values: []float32{1.0, 2.0}, } vectors := []*pinecone.Vector{ { Id: "abc-1", Values: []float32{1.0, 2.0}, 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) }
type IndexMetric ¶
type IndexMetric string
IndexMetric is the distance 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) 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) 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.
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 IntegrationTests ¶
func (*IntegrationTests) SetupSuite ¶
func (ts *IntegrationTests) SetupSuite()
func (*IntegrationTests) TearDownSuite ¶
func (ts *IntegrationTests) TearDownSuite()
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 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 NamespaceSummary ¶
type NamespaceSummary struct {
VectorCount uint32 `json:"vector_count"`
}
NamespaceSummary is a summary of stats for a Pinecone namespace.
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 "" 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 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.
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 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"` }
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]string }
RerankRequest holds the parameters for calling InferenceService.Rerank and reranking documents by a specified query and model.
Fields:
- Model: "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 ScoredVector ¶
ScoredVector is a vector with an associated similarity score calculated according to the distance metric of the Index.
type ServerlessSpec ¶
ServerlessSpec is the infrastructure specification of a serverless Pinecone Index. Only available for serverless Indexes.
type SparseValues ¶
type SparseValues struct { Indices []uint32 `json:"indices,omitempty"` Values []float32 `json:"values,omitempty"` }
SparseValues is a sparse vector objects, 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 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.