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
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder class for creatingPineconeVectorStore
instances. -
Field Summary
FieldsFields inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
batchingStrategy, embeddingModel
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new PineconeVectorStore using the builder pattern. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a list of documents to the vector store based on the namespace.builder
(EmbeddingModel embeddingModel) Creates a new builder for constructing a PineconeVectorStore instance.createObservationContextBuilder
(String operationName) Create a newVectorStoreObservationContext.Builder
instance.void
Deletes a list of documents by their IDs based on the namespace.void
Adds a list of documents to the vector store.void
Deletes a list of documents by their IDs.protected void
doDelete
(Filter.Expression filterExpression) Template method for concrete implementations to provide filter-based deletion logic.doSimilaritySearch
(SearchRequest request) Perform the actual similarity search operation.<T> Optional<T>
Returns the native client if available in this vector store implementation.similaritySearch
(SearchRequest request, String namespace) Methods inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
add, delete, delete, similaritySearch
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.document.DocumentWriter
write
Methods inherited from interface org.springframework.ai.vectorstore.VectorStore
accept, delete, getName, similaritySearch
-
Field Details
-
CONTENT_FIELD_NAME
- See Also:
-
filterExpressionConverter
-
-
Constructor Details
-
PineconeVectorStore
Creates a new PineconeVectorStore using the builder pattern.- Parameters:
builder
- The configured builder instance
-
-
Method Details
-
builder
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:- embeddingModel (provided to this method)
- apiKey
- indexName
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
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
Adds a list of documents to the vector store.- Specified by:
doAdd
in classAbstractObservationVectorStore
- Parameters:
documents
- The list of documents to be added.
-
delete
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
Deletes a list of documents by their IDs.- Specified by:
doDelete
in classAbstractObservationVectorStore
- Parameters:
documentIds
- The list of document IDs to be deleted.
-
similaritySearch
-
doDelete
Description copied from class:AbstractObservationVectorStore
Template method for concrete implementations to provide filter-based deletion logic.- Overrides:
doDelete
in classAbstractObservationVectorStore
- Parameters:
filterExpression
- Filter expression to identify documents to delete
-
doSimilaritySearch
Description copied from class:AbstractObservationVectorStore
Perform the actual similarity search operation.- Specified by:
doSimilaritySearch
in classAbstractObservationVectorStore
- Parameters:
request
- the search request- Returns:
- the list of documents that match the query request conditions
-
createObservationContextBuilder
Description copied from class:AbstractObservationVectorStore
Create a newVectorStoreObservationContext.Builder
instance.- Specified by:
createObservationContextBuilder
in classAbstractObservationVectorStore
- Parameters:
operationName
- the operation name- Returns:
- the observation context builder
-
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: Optionalclient = 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
-