Skip to content

MongoDB Atlas

MongoDB Atlas is a component that lets you store and search documents in MongoDB Atlas using vector embeddings. It connects to your Atlas cluster, adds documents to a vector index, and can retrieve the most similar documents when you ask a question.

How it Works

When you use this component, it talks to your MongoDB Atlas cluster through the Atlas Vector Search API.

  • Adding data – The component takes the documents you give it, turns them into vectors with an embedding model, and writes them into a collection that has a vector index.
  • Searching – When you give it a query, it turns the query into a vector, looks for the nearest vectors in the index, and returns the matching documents.
  • Retrieving – It can also create a retriever object that other parts of your workflow can call to fetch documents on demand.

All of this happens inside Nappai, so you don’t need to write any code. Just set the fields in the dashboard and the component does the rest.

Operations

This component offers several operations that you can select based on what you need to do. You can only use one operation at a time:

  • Add: Adds the documents you provide to the MongoDB Atlas vector store.
  • Search: Searches the vector store for documents that are most similar to a query you enter.
  • Retriever: Builds a retriever object that can be used by other components to fetch documents later.

To use the component, first select the operation you need in the Operation field.

Inputs

  • Embedding: The embedding model that turns text into vectors.

    • Visible in: Add, Search, Retriever
  • Ingest Data: The documents you want to add to the vector store.

    • Visible in: Add
  • Operation: Choose which operation (Add, Search, or Retriever) the component should perform.

    • Visible in: Add, Search, Retriever
  • Collection Name: The name of the MongoDB collection that holds the vector index.

    • Visible in: Add, Search, Retriever
  • Database Name: The name of the MongoDB database that contains the collection.

    • Visible in: Add, Search, Retriever
  • Index Name: The name of the vector index that has been created in the collection.

    • Visible in: Add, Search, Retriever
  • Number of Results: Number of results to return when searching.

    • Visible in: Add, Search, Retriever
  • Search Query: Enter a search query. Leave empty to retrieve all documents.

    • Visible in: Search

Credential
This component requires a MongoDB ATLAS credential.

  1. First, set up the credential in Nappai’s Credentials section.
  2. Then, select that credential in the Credential field of this component.
    The credential contains the MongoDB Atlas Cluster URI (e.g., mongodb+srv://<user>:<pwd>@cluster0.example.mongodb.net/?retryWrites=true&w=majority).

Outputs

  • Retriever: A retriever object that can be used by downstream components to fetch documents.
  • Results: The list of documents returned by a search.
  • Vector Store: The underlying vector store object that represents the connection to MongoDB Atlas.

Usage Example

Adding Documents

  1. Set Operation to Add.
  2. Choose an Embedding model.
  3. Upload or paste your documents into Ingest Data.
  4. Fill in Database Name, Collection Name, and Index Name.
  5. Click Run.
    The component will store the documents in your Atlas collection.

Searching Documents

  1. Set Operation to Search.
  2. Choose the same Embedding model you used when adding data.
  3. Enter a Search Query (e.g., “What are the benefits of using MongoDB Atlas?”).
  4. Set Number of Results to the number of documents you want back.
  5. Click Run.
    The component returns the most similar documents in the Results output.
  • OpenAI Vector Store – Stores and searches documents using OpenAI embeddings.
  • FAISS Vector Store – Uses the FAISS library for fast similarity search.
  • Chroma Vector Store – Stores vectors in the Chroma database.

Tips and Best Practices

  • Use the same embedding model for both adding and searching to keep vector spaces consistent.
  • Keep Number of Results low (e.g., 4–10) for quick responses.
  • Make sure the vector index in MongoDB Atlas is properly configured for the dimensionality of your embeddings.
  • Store only the data you need in the collection; large documents can slow down searches.
  • Test with a small set of documents first to verify that the index works before adding thousands of records.

Security Considerations

  • Store your MongoDB Atlas credentials in Nappai’s secure credential store; never hard‑code them in a workflow.
  • The component uses the credential’s Cluster URI, so ensure that the URI is correct and that the user account has only the permissions it needs.
  • When retrieving documents, be mindful of sensitive data that may be returned; filter or redact as necessary before sending it to downstream components.