AzureCosmosDBMongoDBVectorStore
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:75
Azure Cosmos DB for MongoDB vCore vector store. To use this, you should have both:
- the
mongodb
NPM package installed - a connection string associated with a MongoDB VCore Cluster
You do not need to create a database or collection, it will be created automatically.
You also need an index on the collection, which is by default be created
automatically using the createIndex
method.
Extends
Section titled “Extends”BaseVectorStore
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AzureCosmosDBMongoDBVectorStore(
init
):AzureCosmosDBMongoDBVectorStore
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:106
Parameters
Section titled “Parameters”Partial
<AzureCosmosDBMongoDBVectorStore
> & object
& VectorStoreBaseParams
Returns
Section titled “Returns”AzureCosmosDBMongoDBVectorStore
Overrides
Section titled “Overrides”BaseVectorStore.constructor
Properties
Section titled “Properties”storesText
Section titled “storesText”storesText:
boolean
=true
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:76
Overrides
Section titled “Overrides”BaseVectorStore.storesText
flatMetadata
Section titled “flatMetadata”flatMetadata:
boolean
=true
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:77
dbName
Section titled “dbName”dbName:
string
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:79
collectionName
Section titled “collectionName”collectionName:
string
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:81
indexedMetadataFields
Section titled “indexedMetadataFields”indexedMetadataFields:
string
[]
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:83
mongodbClient
Section titled “mongodbClient”mongodbClient:
MongoClient
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:88
The used MongoClient. If not given, a new MongoClient is created based on the MONGODB_URI env variable.
indexName
Section titled “indexName”indexName:
string
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:90
embeddingKey
Section titled “embeddingKey”embeddingKey:
string
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:92
idKey:
string
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:94
textKey
Section titled “textKey”textKey:
string
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:96
metadataKey
Section titled “metadataKey”metadataKey:
string
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:98
indexOptions
Section titled “indexOptions”indexOptions:
AzureCosmosDBMongoDBIndexOptions
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:100
Methods
Section titled “Methods”client()
Section titled “client()”client():
MongoClient
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:140
Returns
Section titled “Returns”MongoClient
Overrides
Section titled “Overrides”BaseVectorStore.client
ensureCollection()
Section titled “ensureCollection()”ensureCollection():
Promise
<Collection
<Document
>>
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:144
Returns
Section titled “Returns”Promise
<Collection
<Document
>>
add(
nodes
):Promise
<string
[]>
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:156
Parameters
Section titled “Parameters”BaseNode
<Metadata
>[]
Returns
Section titled “Returns”Promise
<string
[]>
Overrides
Section titled “Overrides”BaseVectorStore.add
delete()
Section titled “delete()”delete(
id
,deleteOptions?
):Promise
<void
>
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:194
Removes specified documents from the AzureCosmosDBMongoDBVectorStore.
Parameters
Section titled “Parameters”string
deleteOptions?
Section titled “deleteOptions?”object
Returns
Section titled “Returns”Promise
<void
>
A promise that resolves when the documents have been removed.
Overrides
Section titled “Overrides”BaseVectorStore.delete
query()
Section titled “query()”query(
query
,options
):Promise
<VectorStoreQueryResult
>
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:204
Parameters
Section titled “Parameters”VectorStoreQuery
options
Section titled “options”AzureCosmosDBMongoDBQueryOptions
Returns
Section titled “Returns”Promise
<VectorStoreQueryResult
>
Overrides
Section titled “Overrides”BaseVectorStore.query
createIndex()
Section titled “createIndex()”createIndex(
dimensions
,indexType
,similarity
):Promise
<void
>
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:283
Creates an index on the collection with the specified index name during instance construction.
Setting the numLists parameter correctly is important for achieving good accuracy and performance. Since the vector store uses IVF as the indexing strategy, you should create the index only after you have loaded a large enough sample documents to ensure that the centroids for the respective buckets are faily distributed.
As for the compression, the following options are available:
- “half” - half precision compression for HNSW and IVF indexes
- “pq” - product quantization compression for DiskANN indexes More information on the compression options can be found in the: https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/product-quantization
Parameters
Section titled “Parameters”dimensions
Section titled “dimensions”Number of dimensions for vector similarity. The maximum number of supported dimensions is 2000. If no number is provided, it will be determined automatically by embedding a short text.
undefined
| number
indexType
Section titled “indexType”Index Type for Mongo vCore index.
"ivf"
| "hnsw"
| "diskann"
similarity
Section titled “similarity”AzureCosmosDBMongoDBSimilarityType
= AzureCosmosDBMongoDBSimilarityType.COS
Similarity metric to use with the IVF index. Possible options are:
- CosmosDBSimilarityType.COS (cosine distance)
- CosmosDBSimilarityType.L2 (Euclidean distance)
- CosmosDBSimilarityType.IP (inner product)
Returns
Section titled “Returns”Promise
<void
>
A promise that resolves when the index has been created.
checkIndexExists()
Section titled “checkIndexExists()”checkIndexExists():
Promise
<boolean
>
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:348
Checks if the specified index name during instance construction exists on the collection.
Returns
Section titled “Returns”Promise
<boolean
>
A promise that resolves to a boolean indicating if the index exists.
deleteIndex()
Section titled “deleteIndex()”deleteIndex(
indexName
):Promise
<void
>
Defined in: .build/typescript/packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts:358
Deletes the index specified during instance construction if it exists.
Parameters
Section titled “Parameters”indexName
Section titled “indexName”string
Returns
Section titled “Returns”Promise
<void
>
A promise that resolves when the index has been deleted.