Tutorial: Building a RAG Chat App with MongoDB Atlas Document Store
Learn how to build a chat system running on your data in MongoDB Atlas.
- Level: Beginner
- Time to complete: 20 minutes
- Prerequisites:
- A basic knowledge of pipelines and indexes in deepset. For more information, see Pipelines and Indexes.
- Understanding of document stores. For details, see Document Stores.
- A workspace where you'll create the pipeline. For help, see Quick Start Guide.
- OpenAI API key as this pipeline uses GPT-4o.
- A MongoDB account with a cluster containing the
mflix
sample dataset. For help, see MongoDB Atlas documentation:
- Goal: After completing this tutorial, you will have built a chat application that runs on the sample movie dataset in MongoDB Atlas. It uses both full text search and semantic search to retrieve relevant documents.
Connect deepset to MongoDB Atlas
You need the MongoDB Atlas connection string.
-
Log in to MongoDB Atlas and open your project overview.
-
In the Application Development section click Get connection string, and copy the connection string in step 3.
-
Go to deepset AI Platform, click your initials in the top right corner, and choose Connections.
-
Scroll down to MongoDB and click Connect next to it.
-
Paste your MongoDB connection string replacing
db_password
with your database password and click Connect.
Result: deepset AI Platform is connected to your MongoDB Atlas database, which means that deepset can access data in your MongoDB Atlas database.
Create a Search Index for Your MongoDB Collection
Create Full Text Search Index
First, create a full text search index for keyword searches. For details and other methods of creating the index, see Atlas Search in MongoDB Atlas documentation.
-
In MongoDB Atlas, open your cluster, and click the Atlas Search tab.
-
Click Create Search Index.
-
Choose Atlas Search as the index type.
-
Type
text_index
as the index name. -
Choose embedded_movies as the collection.
-
Choose Visual Editor as the configuration method and click Next.
-
Click Create Search Index.
Result: You have created a full text search index called text_search
. It's listed under Atlas Search in your cluster view. You may need to wait a while until Atlas builds your index and its status changes to Ready.

Add Field Mapping
-
On the Atlas Search tab, click More Actions next to your text index and choose Edit With Visual Editor.
-
On the Index Overview tab, scroll down to Field Mappings, and choose Add Field Mapping.
-
Find Field Name, choose fullplot, and click Add.
-
Save your settings.
Result: You added fullplot
as your index field. It's now showing under Index Fields in the Atlas Search tab.
Create a Vector Search Index
Now, you'll create a vector search index for semantic searches. You can also follow MongoDB Atlas documentation on Atlas Vector Search to complete this step.
-
In MongoDB Atlas, on the Atlas Search tab, click CREATE SEARCH INDEX.
-
Choose Vector Search as its type.
-
Leave
vector_index
as the name. -
Choose embedded_movies as the collection.
-
Choose Visual Editor as the configuration method and click Next.
-
Make sure
plot_embedding
is chosen as the path of the Vector Field. -
Choose the similarity method and click Next.
-
Review your vector index configuration and click Create Vector Search Index.
Result: You have create a vector search index on the plot_embedding field. The index is listed under the Atlas Search tab. You may need to wait a while until Atlas builds it and the index is ready.

Create a RAG Chat Application
- In deepset AI Platform go to Pipeline Templates.
- Choose the Conversational category and find the MongoDB Atlas RAG Chat GPT-4o template.
- Hover over the template and click Use Template.
- Leave the default name and click Create Pipeline.
- On the Pipeline Builder page, click Deploy.
Result: Congratulations! You have created a RAG chat application that uses gpt-4o and runs on the sample dataset in your MongoDB Atlas database. You can now try it out in Playground. For instructions, see Testing Your Pipeline.
Indexing Status
Since MongoDB Atlas is an external document store, you won't be able to view indexing status or see which files are part of your index. However, you can access the logs for insights into the indexing process.
For details, read Document Stores.
Updated about 6 hours ago