Class AzureVectorStore
java.lang.Object
org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
org.springframework.ai.vectorstore.azure.AzureVectorStore
- All Implemented Interfaces:
Consumer<List<Document>>
,DocumentWriter
,VectorStore
,org.springframework.beans.factory.InitializingBean
public class AzureVectorStore
extends AbstractObservationVectorStore
implements org.springframework.beans.factory.InitializingBean
Uses Azure Cognitive Search as a backing vector store. Documents can be preloaded into
a Cognitive Search index and managed via Azure tools or added and managed through this
VectorStore. The underlying index is configured in the provided Azure
SearchIndexClient.
- Author:
- Greg Meyer, Xiangyang Yu, Christian Tzolov, Josh Long, Thomas Vitale, Soby Chacko
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder class for creatingAzureVectorStore
instances.static final record
-
Field Summary
FieldsFields inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
batchingStrategy, embeddingModel
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AzureVectorStore
(AzureVectorStore.Builder builder) Protected constructor that accepts a builder instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
static AzureVectorStore.Builder
builder
(com.azure.search.documents.indexes.SearchIndexClient searchIndexClient, EmbeddingModel embeddingModel) createObservationContextBuilder
(String operationName) Create a newVectorStoreObservationContext.Builder
instance.void
Perform the actual add operation.void
Perform the actual delete operation.doSimilaritySearch
(SearchRequest request) Perform the actual similarity search operation.<T> Optional<T>
Returns the native client if available in this vector store implementation.similaritySearch
(String query) Retrieves documents by query embedding similarity using the defaultSearchRequest
's' search criteria.Methods inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
add, delete, delete, doDelete, 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
-
Field Details
-
DEFAULT_INDEX_NAME
- See Also:
-
-
Constructor Details
-
AzureVectorStore
Protected constructor that accepts a builder instance. This is the preferred way to create new AzureVectorStore instances.- Parameters:
builder
- the configured builder instance
-
-
Method Details
-
builder
public static AzureVectorStore.Builder builder(com.azure.search.documents.indexes.SearchIndexClient searchIndexClient, EmbeddingModel embeddingModel) -
doAdd
Description copied from class:AbstractObservationVectorStore
Perform the actual add operation.- Specified by:
doAdd
in classAbstractObservationVectorStore
- Parameters:
documents
- the documents to add
-
doDelete
Description copied from class:AbstractObservationVectorStore
Perform the actual delete operation.- Specified by:
doDelete
in classAbstractObservationVectorStore
- Parameters:
documentIds
- the list of document IDs to delete
-
similaritySearch
Description copied from interface:VectorStore
Retrieves documents by query embedding similarity using the defaultSearchRequest
's' search criteria.- Specified by:
similaritySearch
in interfaceVectorStore
- Parameters:
query
- Text to use for embedding similarity comparison.- Returns:
- Returns a list of documents that have embeddings similar to the query text embedding.
-
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
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
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. - Specified by:
getNativeClient
in interfaceVectorStore
- Type Parameters:
T
- The type of the native client- Returns:
- Optional containing native client if available, empty Optional otherwise
-