Class: AzureCosmosDBMongoDBVectorStore
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
Constructors
new AzureCosmosDBMongoDBVectorStore()
new AzureCosmosDBMongoDBVectorStore(
init
):AzureCosmosDBMongoDBVectorStore
Parameters
• init: Partial
<AzureCosmosDBMongoDBVectorStore
> & object
& VectorStoreBaseParams
Returns
AzureCosmosDBMongoDBVectorStore
Overrides
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:91
Properties
collectionName
collectionName:
string
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:66
dbName
dbName:
string
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:64
embeddingKey
embeddingKey:
string
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:77
embedModel
embedModel:
BaseEmbedding
Inherited from
Defined in
packages/llamaindex/src/vector-store/types.ts:92
flatMetadata
flatMetadata:
boolean
=true
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:62
idKey
idKey:
string
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:79
indexedMetadataFields
indexedMetadataFields:
string
[]
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:68
indexName
indexName:
string
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:75
indexOptions
indexOptions:
AzureCosmosDBMongoDBIndexOptions
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:85
isEmbeddingQuery?
optional
isEmbeddingQuery:boolean
Inherited from
BaseVectorStore
.isEmbeddingQuery
Defined in
packages/llamaindex/src/vector-store/types.ts:94
metadataKey
metadataKey:
string
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:83
mongodbClient
mongodbClient:
MongoClient
The used MongoClient. If not given, a new MongoClient is created based on the MONGODB_URI env variable.
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:73
storesText
storesText:
boolean
=true
Overrides
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:61
textKey
textKey:
string
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:81
Methods
add()
add(
nodes
):Promise
<string
[]>
Parameters
Returns
Promise
<string
[]>
Overrides
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:139
checkIndexExists()
checkIndexExists():
Promise
<boolean
>
Checks if the specified index name during instance construction exists on the collection.
Returns
Promise
<boolean
>
A promise that resolves to a boolean indicating if the index exists.
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:310
client()
client():
MongoClient
Returns
MongoClient
Overrides
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:123
createIndex()
createIndex(
dimensions
,indexType
,similarity
):Promise
<void
>
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.
Parameters
• dimensions: undefined
| number
= undefined
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.
• indexType: "hnsw"
| "ivf"
| "diskann"
= "ivf"
Index Type for Mongo vCore index.
• 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
Promise
<void
>
A promise that resolves when the index has been created.
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:257
delete()
delete(
id
,deleteOptions
?):Promise
<void
>
Removes specified documents from the AzureCosmosDBMongoDBVectorStore.
Parameters
• id: string
• deleteOptions?: object
Returns
Promise
<void
>
A promise that resolves when the documents have been removed.
Overrides
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:177
deleteIndex()
deleteIndex(
indexName
):Promise
<void
>
Deletes the index specified during instance construction if it exists.
Parameters
• indexName: string
Returns
Promise
<void
>
A promise that resolves when the index has been deleted.
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:320
ensureCollection()
ensureCollection():
Promise
<Collection
<Document
>>
Returns
Promise
<Collection
<Document
>>
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:127
query()
query(
query
,options
?):Promise
<VectorStoreQueryResult
>
Parameters
• query: VectorStoreQuery
• options?: object
Returns
Promise
<VectorStoreQueryResult
>
Overrides
Defined in
packages/llamaindex/src/vector-store/AzureCosmosDBMongoVectorStore.ts:187