MongoDBAtlasVectorSearch#

class llama_index.vector_stores.MongoDBAtlasVectorSearch(mongodb_client: Optional[Any] = None, db_name: str = 'default_db', collection_name: str = 'default_collection', index_name: str = 'default', id_key: str = 'id', embedding_key: str = 'embedding', text_key: str = 'text', metadata_key: str = 'metadata', insert_kwargs: Optional[Dict] = None, **kwargs: Any)#

Bases: VectorStore

MongoDB Atlas Vector Store.

To use, you should have both: - the pymongo python package installed - a connection string associated with a MongoDB Atlas Cluster that has an Atlas Vector Search index

Attributes Summary

client

Return MongoDB client.

flat_metadata

stores_text

Methods Summary

add(nodes, **add_kwargs)

Add nodes to index.

delete(ref_doc_id, **delete_kwargs)

Delete nodes using with ref_doc_id.

query(query, **kwargs)

Query index for top k most similar nodes.

Attributes Documentation

client#

Return MongoDB client.

flat_metadata: bool = True#
stores_text: bool = True#

Methods Documentation

add(nodes: List[BaseNode], **add_kwargs: Any) List[str]#

Add nodes to index.

Parameters

nodes – List[BaseNode]: list of nodes with embeddings

Returns

A List of ids for successfully added nodes.

delete(ref_doc_id: str, **delete_kwargs: Any) None#

Delete nodes using with ref_doc_id.

Parameters

ref_doc_id (str) – The doc_id of the document to delete.

query(query: VectorStoreQuery, **kwargs: Any) VectorStoreQueryResult#

Query index for top k most similar nodes.

Parameters

query – a VectorStoreQuery object.

Returns

A VectorStoreQueryResult containing the results of the query.