Class AzureVectorStore
java.lang.Object
org.springframework.ai.vectorstore.azure.AzureVectorStore
- All Implemented Interfaces:
Consumer<List<Document>>
,DocumentWriter
,VectorStore
,org.springframework.beans.factory.InitializingBean
public class AzureVectorStore
extends Object
implements VectorStore, 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
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAzureVectorStore
(com.azure.search.documents.indexes.SearchIndexClient searchIndexClient, EmbeddingClient embeddingClient) Constructs a new AzureCognitiveSearchVectorStore.AzureVectorStore
(com.azure.search.documents.indexes.SearchIndexClient searchIndexClient, EmbeddingClient embeddingClient, List<AzureVectorStore.MetadataField> filterMetadataFields) Constructs a new AzureCognitiveSearchVectorStore. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds list ofDocument
s to the vector store.void
Deletes documents from the vector store.void
setDefaultSimilarityThreshold
(Double similarityThreshold) Sets the a default similarity threshold for returned documents.void
setDefaultTopK
(int topK) Sets the a default maximum number of similar documents returned.void
setIndexName
(String indexName) Change the Index Name.similaritySearch
(String query) Retrieves documents by query embedding similarity using the defaultSearchRequest
's' search criteria.similaritySearch
(SearchRequest request) Retrieves documents by query embedding similarity and metadata filters to retrieve exactly the number of nearest-neighbor results that match the request criteria.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.vectorstore.VectorStore
accept
-
Field Details
-
DEFAULT_INDEX_NAME
- See Also:
-
-
Constructor Details
-
AzureVectorStore
public AzureVectorStore(com.azure.search.documents.indexes.SearchIndexClient searchIndexClient, EmbeddingClient embeddingClient) Constructs a new AzureCognitiveSearchVectorStore.- Parameters:
searchIndexClient
- A pre-configured AzureSearchIndexClient
that CRUD for Azure search indexes and factory forSearchClient
.embeddingClient
- The client for embedding operations.
-
AzureVectorStore
public AzureVectorStore(com.azure.search.documents.indexes.SearchIndexClient searchIndexClient, EmbeddingClient embeddingClient, List<AzureVectorStore.MetadataField> filterMetadataFields) Constructs a new AzureCognitiveSearchVectorStore.- Parameters:
searchIndexClient
- A pre-configured AzureSearchIndexClient
that CRUD for Azure search indexes and factory forSearchClient
.embeddingClient
- The client for embedding operations.filterMetadataFields
- List of metadata fields (as field name and type) that can be used in similarity search query filter expressions.
-
-
Method Details
-
setIndexName
Change the Index Name.- Parameters:
indexName
- The Azure VectorStore index name to use.
-
setDefaultTopK
public void setDefaultTopK(int topK) Sets the a default maximum number of similar documents returned.- Parameters:
topK
- The default maximum number of similar documents returned.
-
setDefaultSimilarityThreshold
Sets the a default similarity threshold for returned documents.- Parameters:
similarityThreshold
- The a default similarity threshold for returned documents.
-
add
Description copied from interface:VectorStore
Adds list ofDocument
s to the vector store.- Specified by:
add
in interfaceVectorStore
- Parameters:
documents
- the list of documents to store. Throws an exception if the underlying provider checks for duplicate IDs.
-
delete
Description copied from interface:VectorStore
Deletes documents from the vector store.- Specified by:
delete
in interfaceVectorStore
- Parameters:
documentIds
- list of document ids for which documents will be removed.- Returns:
-
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.
-
similaritySearch
Description copied from interface:VectorStore
Retrieves documents by query embedding similarity and metadata filters to retrieve exactly the number of nearest-neighbor results that match the request criteria.- Specified by:
similaritySearch
in interfaceVectorStore
- Parameters:
request
- Search request for set search parameters, such as the query text, topK, similarity threshold and metadata filter expressions.- Returns:
- Returns documents th match the query request conditions.
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-