Class AzureCognitiveSearchMemoryStore
- java.lang.Object
-
- com.microsoft.semantickernel.connectors.memory.azurecognitivesearch.AzureCognitiveSearchMemoryStore
-
- All Implemented Interfaces:
Buildable,MemoryStore
public class AzureCognitiveSearchMemoryStore extends Object implements MemoryStore
Semantic Memory implementation using Azure Cognitive Search. For more information about Azure Cognitive Search {@see https://learn.microsoft.com/azure/search/search-what-is-azure-search}
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.microsoft.semantickernel.memory.MemoryStore
MemoryStore.Builder<T extends MemoryStore>
-
-
Constructor Summary
Constructors Constructor Description AzureCognitiveSearchMemoryStore(com.azure.search.documents.indexes.SearchIndexAsyncClient searchIndexAsyncClient, Function<com.azure.search.documents.SearchDocument,MemoryRecord> memoryRecordMapper)Create a new instance of memory storage using Azure Cognitive Search.AzureCognitiveSearchMemoryStore(String endpoint, com.azure.core.credential.TokenCredential credentials)Create a new instance of memory storage using Azure Cognitive Search.AzureCognitiveSearchMemoryStore(String endpoint, String apiKey)Create a new instance of memory storage using Azure Cognitive Search.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Mono<Void>createCollectionAsync(String collectionName)reactor.core.publisher.Mono<Void>deleteCollectionAsync(String collectionName)reactor.core.publisher.Mono<Boolean>doesCollectionExistAsync(String collectionName)reactor.core.publisher.Mono<MemoryRecord>getAsync(String collectionName, String key, boolean withEmbedding)reactor.core.publisher.Mono<Collection<MemoryRecord>>getBatchAsync(String collectionName, Collection<String> keys, boolean withEmbedding)reactor.core.publisher.Mono<List<String>>getCollectionsAsync()reactor.core.publisher.Mono<reactor.util.function.Tuple2<MemoryRecord,Float>>getNearestMatchAsync(String collectionName, Embedding embedding, float minRelevanceScore, boolean withEmbedding)reactor.core.publisher.Mono<Collection<reactor.util.function.Tuple2<MemoryRecord,Float>>>getNearestMatchesAsync(String collectionName, Embedding embedding, int limit, float minRelevanceScore, boolean withEmbedding)reactor.core.publisher.Mono<Collection<reactor.util.function.Tuple2<MemoryRecord,Float>>>getNearestMatchesAsync(String collectionName, Embedding embedding, int limit, float minRelevanceScore, boolean withEmbedding, Function<com.azure.search.documents.SearchDocument,MemoryRecord> memoryRecordMapper)Gets the nearest matches to theEmbeddingof typeFloat.reactor.core.publisher.Mono<Void>removeAsync(String collectionName, String key)reactor.core.publisher.Mono<Void>removeBatchAsync(String collectionName, Collection<String> keys)reactor.core.publisher.Mono<String>upsertAsync(String collectionName, MemoryRecord record)reactor.core.publisher.Mono<Collection<String>>upsertBatchAsync(String collectionName, Collection<MemoryRecord> records)
-
-
-
Constructor Detail
-
AzureCognitiveSearchMemoryStore
public AzureCognitiveSearchMemoryStore(@Nonnull String endpoint, @Nonnull String apiKey)
Create a new instance of memory storage using Azure Cognitive Search.- Parameters:
endpoint- Azure Cognitive Search URI, e.g. "https://contoso.search.windows.net"apiKey- Azure API Key
-
AzureCognitiveSearchMemoryStore
public AzureCognitiveSearchMemoryStore(@Nonnull String endpoint, @Nonnull com.azure.core.credential.TokenCredential credentials)
Create a new instance of memory storage using Azure Cognitive Search.- Parameters:
endpoint- Azure Cognitive Search URI, e.g. "https://contoso.search.windows.net"credentials- Azure service credentials
-
AzureCognitiveSearchMemoryStore
public AzureCognitiveSearchMemoryStore(@Nonnull com.azure.search.documents.indexes.SearchIndexAsyncClient searchIndexAsyncClient, @Nullable Function<com.azure.search.documents.SearchDocument,MemoryRecord> memoryRecordMapper)
Create a new instance of memory storage using Azure Cognitive Search.- Parameters:
searchIndexAsyncClient- the Azure search documents index client to use
-
-
Method Detail
-
createCollectionAsync
public reactor.core.publisher.Mono<Void> createCollectionAsync(@Nonnull String collectionName)
- Specified by:
createCollectionAsyncin interfaceMemoryStore
-
getCollectionsAsync
public reactor.core.publisher.Mono<List<String>> getCollectionsAsync()
- Specified by:
getCollectionsAsyncin interfaceMemoryStore
-
doesCollectionExistAsync
public reactor.core.publisher.Mono<Boolean> doesCollectionExistAsync(@Nonnull String collectionName)
- Specified by:
doesCollectionExistAsyncin interfaceMemoryStore
-
deleteCollectionAsync
public reactor.core.publisher.Mono<Void> deleteCollectionAsync(@Nonnull String collectionName)
- Specified by:
deleteCollectionAsyncin interfaceMemoryStore
-
upsertAsync
public reactor.core.publisher.Mono<String> upsertAsync(@Nonnull String collectionName, @Nonnull MemoryRecord record)
- Specified by:
upsertAsyncin interfaceMemoryStore
-
upsertBatchAsync
public reactor.core.publisher.Mono<Collection<String>> upsertBatchAsync(@Nonnull String collectionName, Collection<MemoryRecord> records)
- Specified by:
upsertBatchAsyncin interfaceMemoryStore
-
getAsync
public reactor.core.publisher.Mono<MemoryRecord> getAsync(@Nonnull String collectionName, @Nonnull String key, boolean withEmbedding)
- Specified by:
getAsyncin interfaceMemoryStore
-
getBatchAsync
public reactor.core.publisher.Mono<Collection<MemoryRecord>> getBatchAsync(@Nonnull String collectionName, @Nonnull Collection<String> keys, boolean withEmbedding)
- Specified by:
getBatchAsyncin interfaceMemoryStore
-
getNearestMatchAsync
public reactor.core.publisher.Mono<reactor.util.function.Tuple2<MemoryRecord,Float>> getNearestMatchAsync(@Nonnull String collectionName, @Nonnull Embedding embedding, float minRelevanceScore, boolean withEmbedding)
- Specified by:
getNearestMatchAsyncin interfaceMemoryStore
-
getNearestMatchesAsync
public reactor.core.publisher.Mono<Collection<reactor.util.function.Tuple2<MemoryRecord,Float>>> getNearestMatchesAsync(@Nonnull String collectionName, @Nonnull Embedding embedding, int limit, float minRelevanceScore, boolean withEmbedding)
- Specified by:
getNearestMatchesAsyncin interfaceMemoryStore
-
getNearestMatchesAsync
public reactor.core.publisher.Mono<Collection<reactor.util.function.Tuple2<MemoryRecord,Float>>> getNearestMatchesAsync(@Nonnull String collectionName, @Nonnull Embedding embedding, int limit, float minRelevanceScore, boolean withEmbedding, @Nullable Function<com.azure.search.documents.SearchDocument,MemoryRecord> memoryRecordMapper)
Gets the nearest matches to theEmbeddingof typeFloat. Does not guarantee that the collection exists.If a memoryRecordMapper is provided this overrides any mapper provided when constructing this memory store.
- Parameters:
collectionName- The name associated with a collection of embeddings.embedding- TheEmbeddingto compare the collection's embeddings with.limit- The maximum number of similarity results to return.minRelevanceScore- The minimum relevance threshold for returned results.withEmbedding- If true, the embeddings will be returned in the memory records.memoryRecordMapper- a mapper that controls how to map the search document to a memory record- Returns:
- A collection of tuples where item1 is a
MemoryRecordand item2 is its similarity score as aFloat.
-
removeAsync
public reactor.core.publisher.Mono<Void> removeAsync(@Nonnull String collectionName, @Nonnull String key)
- Specified by:
removeAsyncin interfaceMemoryStore
-
removeBatchAsync
public reactor.core.publisher.Mono<Void> removeBatchAsync(@Nonnull String collectionName, @Nonnull Collection<String> keys)
- Specified by:
removeBatchAsyncin interfaceMemoryStore
-
-