Class AzureCosmosDbMongoVCoreEmbeddingStore
java.lang.Object
dev.langchain4j.store.embedding.azure.cosmos.mongo.vcore.AzureCosmosDbMongoVCoreEmbeddingStore
- All Implemented Interfaces:
EmbeddingStore<TextSegment>
public class AzureCosmosDbMongoVCoreEmbeddingStore
extends Object
implements EmbeddingStore<TextSegment>
Represents an Azure CosmosDB Mongo vCore as an embedding store.
More info to set up MongoDb as vectorDatabase.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
static enum
-
Constructor Summary
ConstructorsConstructorDescriptionAzureCosmosDbMongoVCoreEmbeddingStore
(com.mongodb.client.MongoClient mongoClient, String connectionString, String databaseName, String collectionName, String indexName, String applicationName, com.mongodb.client.model.CreateCollectionOptions createCollectionOptions, Boolean createIndex, String kind, Integer numLists, Integer dimensions, Integer m, Integer efConstruction, Integer efSearch) -
Method Summary
Modifier and TypeMethodDescriptionAdds a given embedding to the store.add
(Embedding embedding, TextSegment textSegment) Adds a given embedding and the corresponding content that has been embedded to the store.void
Adds a given embedding to the store.Adds multiple embeddings to the store.void
Adds multiple embeddings and their corresponding contents that have been embedded to the store.builder()
findRelevant
(Embedding referenceEmbedding, int maxResults, double minScore) search
(EmbeddingSearchRequest request) Searches for the most similar (closest in the embedding space)Embedding
s.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.store.embedding.EmbeddingStore
addAll, generateIds, remove, removeAll, removeAll, removeAll
-
Constructor Details
-
AzureCosmosDbMongoVCoreEmbeddingStore
public AzureCosmosDbMongoVCoreEmbeddingStore(com.mongodb.client.MongoClient mongoClient, String connectionString, String databaseName, String collectionName, String indexName, String applicationName, com.mongodb.client.model.CreateCollectionOptions createCollectionOptions, Boolean createIndex, String kind, Integer numLists, Integer dimensions, Integer m, Integer efConstruction, Integer efSearch) - Parameters:
mongoClient
- - mongoClient for the Azure CosmosDB Mongo vCoreconnectionString
- - connection string required to connect to Azure Cosmos Mongo vCoredatabaseName
- - databaseName for the mongoDb vCorecollectionName
- - collection name for the mongoDB vCoreindexName
- - index name for the mongoDB vCore collectionapplicationName
- - application name for the client for tracking and loggingcreateCollectionOptions
- - options for creating a collectioncreateIndex
- - set to true if you want the application to create an index, or false if you want to create it manually.kind
- - Type of vector index to create. Possible options are: - vector-ivf - vector-hnsw: available as a preview feature only, to enable visit https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/preview-featuresnumLists
- - This integer is the number of clusters that the inverted file (IVF) index uses to group the vector data. We recommend that numLists is set to documentCount/1000 for up to 1 million documents and to sqrt(documentCount) for more than 1 million documents. Using a numLists value of 1 is akin to performing brute-force search, which has limited performance.dimensions
- - Number of dimensions for vector similarity. The maximum number of supported dimensions is 2000.m
- - used only for vector -hnsw. The max number of connections per layer (16 by default, minimum value is 2, maximum value is 100). Higher m is suitable for datasets with high dimensionality and/or high accuracy requirements.efConstruction
- - used only for vector -hnsw. The size of the dynamic candidate list for constructing the graph (64 by default, minimum value is 4, maximum value is 1000). Higher ef_construction will result in better index quality and higher accuracy, but it will also increase the time required to build the index. ef_construction has to be at least 2 * m.efSearch
- - used only for vector -hnsw. The size of the dynamic candidate list for search (40 by default). A higher value provides better recall at the cost of speed.
-
-
Method Details
-
builder
-
add
Description copied from interface:EmbeddingStore
Adds a given embedding to the store.- Specified by:
add
in interfaceEmbeddingStore<TextSegment>
- Parameters:
embedding
- The embedding to be added to the store.- Returns:
- The auto-generated ID associated with the added embedding.
-
add
Description copied from interface:EmbeddingStore
Adds a given embedding to the store.- Specified by:
add
in interfaceEmbeddingStore<TextSegment>
- Parameters:
id
- The unique identifier for the embedding to be added.embedding
- The embedding to be added to the store.
-
add
Description copied from interface:EmbeddingStore
Adds a given embedding and the corresponding content that has been embedded to the store.- Specified by:
add
in interfaceEmbeddingStore<TextSegment>
- Parameters:
embedding
- The embedding to be added to the store.textSegment
- Original content that was embedded.- Returns:
- The auto-generated ID associated with the added embedding.
-
addAll
Description copied from interface:EmbeddingStore
Adds multiple embeddings to the store.- Specified by:
addAll
in interfaceEmbeddingStore<TextSegment>
- Parameters:
embeddings
- A list of embeddings to be added to the store.- Returns:
- A list of auto-generated IDs associated with the added embeddings.
-
search
Description copied from interface:EmbeddingStore
Searches for the most similar (closest in the embedding space)Embedding
s.
All search criteria are defined inside theEmbeddingSearchRequest
.
EmbeddingSearchRequest.filter()
can be used to filter by various metadata entries (e.g., user/memory ID). Please note that not allEmbeddingStore
implementations supportFilter
ing.- Specified by:
search
in interfaceEmbeddingStore<TextSegment>
- Parameters:
request
- A request to search in anEmbeddingStore
. Contains all search criteria.- Returns:
- An
EmbeddingSearchResult
containing all foundEmbedding
s.
-
findRelevant
public List<EmbeddingMatch<TextSegment>> findRelevant(Embedding referenceEmbedding, int maxResults, double minScore) -
addAll
Description copied from interface:EmbeddingStore
Adds multiple embeddings and their corresponding contents that have been embedded to the store.- Specified by:
addAll
in interfaceEmbeddingStore<TextSegment>
- Parameters:
ids
- A list of IDs associated with the added embeddings.embeddings
- A list of embeddings to be added to the store.embedded
- A list of original contents that were embedded.
-