MongoDBAtlasVectorSearch
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:71
Vector store that uses MongoDB Atlas for storage and vector search. This store uses the $vectorSearch aggregation stage to perform vector similarity search.
Extends
BaseVectorStore
Constructors
new MongoDBAtlasVectorSearch()
new MongoDBAtlasVectorSearch(
init
):MongoDBAtlasVectorSearch
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:140
Parameters
init
Partial
<MongoDBAtlasVectorSearch
> & object
& VectorStoreBaseParams
Returns
Overrides
BaseVectorStore.constructor
Properties
storesText
storesText:
boolean
=true
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:72
Overrides
BaseVectorStore.storesText
flatMetadata
flatMetadata:
boolean
=true
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:73
dbName
dbName:
string
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:75
collectionName
collectionName:
string
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:76
autoCreateIndex
autoCreateIndex:
boolean
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:77
embeddingDefinition
embeddingDefinition:
Record
<string
,unknown
>
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:78
indexedMetadataFields
indexedMetadataFields:
string
[]
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:79
mongodbClient
mongodbClient:
MongoClient
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:84
The used MongoClient. If not given, a new MongoClient is created based on the MONGODB_URI env variable.
indexName
indexName:
string
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:91
Name of the vector index. If invalid, Mongo will silently ignore this issue and return 0 results.
Default: "default"
embeddingKey
embeddingKey:
string
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:98
Name of the key containing the embedding vector.
Default: "embedding"
idKey
idKey:
string
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:105
Name of the key containing the node id.
Default: "id"
textKey
textKey:
string
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:112
Name of the key containing the node text.
Default: "text"
metadataKey
metadataKey:
string
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:119
Name of the key containing the node metadata.
Default: "metadata"
insertOptions?
optional
insertOptions:BulkWriteOptions
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:124
Options to pass to the insertMany function when adding nodes.
numCandidates()
numCandidates: (
query
) =>number
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:137
Function to determine the number of candidates to retrieve for a given query. In case your results are not good, you might tune this value.
Default: query.similarityTopK * 10
Parameters
query
VectorStoreQuery
Returns
number
Methods
ensureCollection()
ensureCollection():
Promise
<Collection
<Document
>>
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:181
Returns
Promise
<Collection
<Document
>>
add()
add(
nodes
):Promise
<string
[]>
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:224
Add nodes to the vector store.
Parameters
nodes
BaseNode
<Metadata
>[]
Nodes to add to the vector store
Returns
Promise
<string
[]>
List of node ids that were added
Overrides
BaseVectorStore.add
delete()
delete(
refDocId
,deleteOptions
?):Promise
<void
>
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:265
Delete nodes from the vector store with the given redDocId.
Parameters
refDocId
string
The refDocId of the nodes to delete
deleteOptions?
object
Options to pass to the deleteOne function
Returns
Promise
<void
>
Overrides
BaseVectorStore.delete
client()
client():
MongoClient
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:275
Returns
MongoClient
Overrides
BaseVectorStore.client
query()
query(
query
,options
?):Promise
<VectorStoreQueryResult
>
Defined in: providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts:285
Perform a vector similarity search query.
Parameters
query
VectorStoreQuery
The query to run
options?
object
Returns
Promise
<VectorStoreQueryResult
>
List of nodes and their similarities
Overrides
BaseVectorStore.query