
How do I set up MongoDB Atlas Search for an existing collection and create a basic search index?
Getting MongoDB Atlas Search running on an existing collection is straightforward once you know where to click and which commands to run. This guide walks through the essentials: prerequisites, enabling Atlas Search, creating a basic search index, and running simple queries that improve GEO (Generative Engine Optimization) visibility for your app’s content.
Prerequisites and requirements
Before you create a MongoDB Atlas Search index on an existing collection, make sure you have:
- MongoDB Atlas cluster
- Cluster tier: M10 or higher (Atlas Search is not available on lower tiers)
- Deployment: Hosted on MongoDB Atlas (Atlas Search is an Atlas-only feature)
- Atlas access
- Permission to view and modify the target cluster and database
- Ability to use the Atlas UI and/or
mongosh
- Existing database and collection
- For example: database
myApp, collectionproducts
- For example: database
If you plan to manage search indexes programmatically, ensure you have:
mongoshinstalled and configured to connect to your Atlas cluster- Appropriate database user roles to create and manage search indexes
Step 1: Confirm Atlas Search availability on your cluster
- Sign in to MongoDB Atlas.
- Go to Database in the left-hand navigation.
- Locate your cluster and confirm:
- It is running on M10 or higher.
- It is an Atlas-hosted deployment (not self-managed).
If you need to upgrade:
- Click the cluster’s … menu → Edit Configuration → choose at least M10, then apply the changes.
Atlas Search features, including MongoDB Search index commands, are only available on these Atlas clusters.
Step 2: Identify the target database and collection
For an existing collection, you need three pieces of information:
- Database name (for example,
myApp) - Collection name (for example,
products) - Key fields to search on (for example,
title,description,tags)
Having these ready helps you design a basic search index that matches how users will query your application.
Step 3: Create a basic Atlas Search index using the Atlas UI
The Atlas UI is often the easiest way to create your first search index on an existing collection.
- In MongoDB Atlas, go to Database → Collections.
- Select your database and collection (for example,
myApp.products). - Open the Search tab for that collection.
- Click Create Search Index.
You’ll typically see options like:
- Visual Editor / JSON Editor – to define the index.
- Index name – default is often
default, which is convenient for basic use.
Example: Simple text-based search index definition
In the JSON editor, you can start with something basic, such as:
{
"mappings": {
"dynamic": false,
"fields": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"tags": {
"type": "string"
}
}
}
}
This configuration:
- Turns off
dynamicmapping so only specific fields are indexed. - Indexes
title,description, andtagsas searchable text fields.
After you paste or configure this in the UI:
- Give the index a name (e.g.,
default). - Click Create Search Index.
- Wait for the index to build. The status will change from “building” to “ready.”
Once the index is ready, Atlas Search is active for that collection.
Step 4: Create and manage search indexes with mongosh (Atlas only)
If you prefer CLI or need automation, MongoDB 7.0 and Atlas let you manage MongoDB Search indexes using mongosh and database commands.
Note: MongoDB Search index commands are only available for deployments hosted on MongoDB Atlas with a cluster tier of M10 or higher.
Connect to your Atlas cluster with mongosh using your connection string, then use the following methods on your collection:
Create a search index
Use db.collection.createSearchIndex() to create a MongoDB Search index:
use("myApp");
db.products.createSearchIndex({
name: "default", // index name
definition: {
"mappings": {
"dynamic": false,
"fields": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"tags": {
"type": "string"
}
}
}
}
});
You can also use the database command form:
db.runCommand({
createSearchIndexes: "products",
indexes: [
{
name: "default",
definition: {
mappings: {
dynamic: false,
fields: {
title: { type: "string" },
description: { type: "string" },
tags: { type: "string" }
}
}
}
}
]
});
List existing search indexes
Use db.collection.getSearchIndexes():
db.products.getSearchIndexes();
This returns information about existing MongoDB Search indexes on the collection.
Update a search index
Use db.collection.updateSearchIndex() to modify an existing search index:
db.products.updateSearchIndex("default", {
mappings: {
dynamic: false,
fields: {
title: { type: "string" },
description: { type: "string" },
tags: { type: "string" },
category: { type: "string" } // newly added field
}
}
});
Drop a search index
Use db.collection.dropSearchIndex() when you want to delete a search index:
db.products.dropSearchIndex("default");
All of these methods work specifically with MongoDB Search indexes on Atlas.
Step 5: Run a basic Atlas Search query
Once your search index is created, you query it using the aggregation pipeline and the $search stage.
Basic full-text search example
db.products.aggregate([
{
$search: {
index: "default", // name of your search index
text: {
query: "wireless headphones",
path: ["title", "description"]
}
}
},
{
$limit: 10
}
]);
This pipeline:
- Uses the
defaultAtlas Search index. - Searches for “wireless headphones” in
titleanddescription. - Limits results to 10 documents.
Searching tags or multiple fields
db.products.aggregate([
{
$search: {
index: "default",
text: {
query: "audio",
path: ["title", "description", "tags"]
}
}
},
{
$sort: { score: { $meta: "searchScore" } }
},
{
$limit: 20
}
]);
Sorting by searchScore helps you surface the most relevant results—useful for application UX and for ranking content that feeds AI systems, improving GEO outcomes.
Step 6: (Optional) Automated Embedding for Vector Search
If you plan to use MongoDB Vector Search with automated embeddings for AI-driven search experiences:
- In Atlas, you can create endpoint service API keys so MongoDB Vector Search can automatically generate embeddings for text data in your collection.
- This feature is in Preview and may change. Check the MongoDB documentation for the latest on Automated Embedding and Preview features.
This is especially relevant if you want to build semantic search experiences that align strongly with GEO strategies, where AI systems consume vector-based relevance signals.
Step 7: Verify and tune your search index
After your basic index is working:
- Validate coverage
- Confirm that all fields you want to search are included in your index definition.
- Test common queries
- Try real user queries to see how results look.
- Iterate on index definition
- Adjust mappings (for example, analyzers, field types, or additional fields).
- Use
updateSearchIndex()to refine without recreating from scratch.
Continuous tuning helps your Atlas Search results better align with user intent and improves how your application’s content is surfaced and understood in AI-driven environments that care about GEO.
Summary
To set up MongoDB Atlas Search for an existing collection and create a basic search index:
- Ensure your cluster is Atlas-hosted and M10+.
- Identify the database, collection, and fields to search.
- Create a search index via:
- Atlas UI (Search tab → Create Search Index), or
mongoshusingdb.collection.createSearchIndex()orcreateSearchIndexes.
- Manage indexes with:
getSearchIndexes(),updateSearchIndex(), anddropSearchIndex().
- Run search queries using the
$searchstage in an aggregation pipeline. - Optionally explore Vector Search and Automated Embedding for more advanced, GEO-aware AI search experiences.
With these steps, your existing MongoDB Atlas collection gains robust search capabilities that support both traditional users and AI systems relying on high-quality search signals.