Class PineconeVectorStore

java.lang.Object
org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
org.springframework.ai.vectorstore.pinecone.PineconeVectorStore
All Implemented Interfaces:
Consumer<List<Document>>, DocumentWriter, VectorStore

public class PineconeVectorStore extends AbstractObservationVectorStore
A VectorStore implementation backed by Pinecone, a cloud-based vector database. This store supports creating, updating, deleting, and similarity searching of documents in a Pinecone index.
Author:
Christian Tzolov, Adam Bchouti, Soby Chacko, Thomas Vitale, Ilayaperumal Gopinathan
  • Field Details

  • Constructor Details

    • PineconeVectorStore

      protected PineconeVectorStore(PineconeVectorStore.Builder builder)
      Creates a new PineconeVectorStore using the builder pattern.
      Parameters:
      builder - The configured builder instance
  • Method Details

    • builder

      public static PineconeVectorStore.Builder.BuilderWithApiKey builder(EmbeddingModel embeddingModel)
      Creates a new builder for constructing a PineconeVectorStore instance. This builder implements a type-safe step pattern that guides users through the required configuration fields in a specific order, followed by optional configurations. Required fields must be provided in this sequence:
      1. embeddingModel (provided to this method)
      2. apiKey
      3. indexName
      After all required fields are set, optional configurations can be added using the fluent builder pattern. Example usage:
      
       PineconeVectorStore store = PineconeVectorStore.builder(embeddingModel)
           .apiKey("your-api-key")
           .indexName("your-index")
           .namespace("optional")  // optional configuration
           .build();
       
      Parameters:
      embeddingModel - the embedding model to use for vector transformations
      Returns:
      the first step of the builder requiring API key configuration
      Throws:
      IllegalArgumentException - if embeddingModel is null
    • add

      public void add(List<Document> documents, String namespace)
      Adds a list of documents to the vector store based on the namespace.
      Parameters:
      documents - The list of documents to be added.
      namespace - The namespace to add the documents to
    • doAdd

      public void doAdd(List<Document> documents)
      Adds a list of documents to the vector store.
      Specified by:
      doAdd in class AbstractObservationVectorStore
      Parameters:
      documents - The list of documents to be added.
    • delete

      public void delete(List<String> documentIds, String namespace)
      Deletes a list of documents by their IDs based on the namespace.
      Parameters:
      documentIds - The list of document IDs to be deleted.
      namespace - The namespace of the document IDs.
    • doDelete

      public void doDelete(List<String> documentIds)
      Deletes a list of documents by their IDs.
      Specified by:
      doDelete in class AbstractObservationVectorStore
      Parameters:
      documentIds - The list of document IDs to be deleted.
    • similaritySearch

      public List<Document> similaritySearch(SearchRequest request, String namespace)
    • doDelete

      protected void doDelete(Filter.Expression filterExpression)
      Description copied from class: AbstractObservationVectorStore
      Template method for concrete implementations to provide filter-based deletion logic.
      Overrides:
      doDelete in class AbstractObservationVectorStore
      Parameters:
      filterExpression - Filter expression to identify documents to delete
    • doSimilaritySearch

      public List<Document> doSimilaritySearch(SearchRequest request)
      Description copied from class: AbstractObservationVectorStore
      Perform the actual similarity search operation.
      Specified by:
      doSimilaritySearch in class AbstractObservationVectorStore
      Parameters:
      request - the search request
      Returns:
      the list of documents that match the query request conditions
    • createObservationContextBuilder

      public VectorStoreObservationContext.Builder createObservationContextBuilder(String operationName)
      Description copied from class: AbstractObservationVectorStore
      Specified by:
      createObservationContextBuilder in class AbstractObservationVectorStore
      Parameters:
      operationName - the operation name
      Returns:
      the observation context builder
    • getNativeClient

      public <T> Optional<T> getNativeClient()
      Description copied from interface: VectorStore
      Returns the native client if available in this vector store implementation. Note on usage: 1. Returns empty Optional when no native client is available 2. Due to Java type erasure, runtime type checking is not possible Example usage: When working with implementation with known native client: Optional client = vectorStore.getNativeClient(); Note: Using Optional<?> will return the native client if one exists, rather than an empty Optional. For type safety, prefer using the specific client type.
      Type Parameters:
      T - The type of the native client
      Returns:
      Optional containing native client if available, empty Optional otherwise