Docs Menu
Docs Home
/ /

Intelligent Assistant in Data Explorer

The intelligent assistant is an AI-powered tool designed for integrated MongoDB development support in Data Explorer. It answers natural language questions, assists with debugging errors, and provides guidance for performance optimization.

To use the intelligent assistant in Data Explorer, first enable AI features in settings.

At the organizational level:

1
  1. If it's not already displayed, select your desired organization from the Organizations menu in the navigation bar.

  2. In the sidebar, click Organization Settings.

The Organization Settings page displays.

2

At the project level:

1
  1. If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. In the sidebar, click Project Settings.

The Project Settings page displays.

2

Set the Enable Data Explorer Generative AI Features toggle to on.

3

For more information about generative AI usage in Data Explorer, see:

  • AI and Data Usage Information

  • FAQ For MongoDB Generative AI Features

To access the intelligent assistant:

1
  1. If it's not already displayed, select the organization that contains your project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your project from the Projects menu in the navigation bar.

  3. In the sidebar, click Data Explorer under the Database heading.

    The Data Explorer displays.

Data Explorer Page with collapsed AI Drawer
click to enlarge

Figure 1. Data Explorer home page with the assistant collapsed.

Data ExplorerPage with opened AI drawer
click to enlarge

Figure 2. The Data Explorer home page with the assistant expanded.

Read-only tools in the Data Explorer's assistant fetch context from your current task or execute database operations against your connected MongoDB deployment with human approval. Unlike conversational responses, these tools may perform actual database queries and return live data from your database.

Assistant tools exhibit the following key characteristics:

  • Read-only: Tools cannot modify, insert, update, or delete data.

  • User-approved: Every tool execution requires explicit user confirmation.

  • Contextual: The assistant accounts for your current database, collection, and connection when deciding to call tools.

  • Live data: Results come from your connected MongoDB deployment in real-time.

The following tools fetch sensitive content for users and require confirmation. These tools do not interact with the database, but require user confirmation before use:

Data Explorer Tool Name
Description

get-current-query

Extracts active MongoDB query parameters from the query bar

get-current-pipeline

Extracts active aggregation pipeline from the aggregation builder

Database Tool Name
Description

list-databases

Displays all databases available in your MongoDB deployment with their storage sizes.

list-collections

Shows all collections within a specific database.

find

Retrieves actual documents from a collection that match specific search criteria.

count

Quickly returns the total number of documents in a collection without retrieving the documents themselves.

aggregate

Performs complex data processing operations like grouping, filtering, transforming, and calculating statstics across documents.

collection-indexes

Lists all indexes defined on a collection.

collection-schema

Analyzes a collection to reveal the structure of documents, including field names and data types.

collection-storage-size

Reports the physical disk space occupied by a collection, including both data and indexes.

db-stats

Provides a comprehensive overview of database health, including collection counts, document totals, storage usage, and index statistics.

mongodb-logs

Retrieves recent server logs for troubleshooting, performance monitoring, and security auditing.

explain

Shows the detailed query execution plan and performance statistics, revealing how MongoDB processes a query and whether it uses indexes.

Note

The aggregation pipeline stages $out and $merge are not supported in tool calling because they perform write operations. The assistant only supports read-only tools.

1

Tools are enabled by default, but you can toggle them on or off using the Tools button in the input bar.

2

Make sure you have an active connection and are viewing the relevant page. To ask a question, you must be on a tab that relates to your active connection.

3

Submit a prompt inquiring about your data, for example: "List all databases".

4

The assistant detects your intent and displays a tool card in a pending state. This list enumerates the possible elements that the tool card can show:

  • Tool name operation

  • Deployment (host/endpoint)

  • Database and collection being queried

  • Any parameters or filters

  • Run and Cancel buttons

For the above example, the tool card shows for "list-databases".

5
6

Example result:

Here are the databases found on your MongoDB deployment:
- sample_mflix (Size: 183,685,120 bytes)
- admin (Size: 364,544 bytes)
- local (Size: 21,907,722,240 bytes)
If you want details about collections in any of these databases,
just let me know!

The following scenarios show several uses of the intelligent assistant in Data Explorer.

Ask the intelligent assistant to analyze the output of your MongoDB Compass query:

Interpret this explain plan for me.
## Summary
- **Query Logic:** This pipeline counts the number of Italian restaurants in Manhattan by first filtering documents and then aggregating the count.
- **Performance:** Fair
- **Recommendations:** Create a compound index on `{ borough: 1, cuisine: 1 }` to optimize document retrieval.
## Details
### Query Logic
1. `$match`: Filters documents where `borough` is "Manhattan" and `cuisine` is "Italian".
2. `$count`: Counts the number of documents matching the filter and outputs the total.
### Performance Analysis
- The winning plan uses an index scan on the `cuisine` field (`cuisine_1`) and applies an in-memory filter for `borough` ("Manhattan").
- Both `totalKeysExamined` and `totalDocsExamined` are high (43,207), which implies that every document with `cuisine: "Italian"` is examined and then filtered by `borough`.
- No compound index exists, meaning MongoDB cannot efficiently combine both filter criteria in a single index lookup.
- The pipeline does properly filter before counting, but index usage is only partial, causing increased resource usage.
### Recommendations
- Create a compound index on `{ borough: 1, cuisine: 1 }` to allow MongoDB to retrieve documents matching both criteria directly from the index, minimizing documents examined.
- This optimization will reduce execution time and system load without changing the output of your aggregation pipeline.
Below is the recommended Aggregation Pipeline. This optimized Aggregation Pipeline will leverage the compound index to scan fewer documents, as both filter criteria are present in the index.
```json
[
{ "$match": { "borough": "Manhattan", "cuisine": "Italian" } },
{ "$count": "totalItalianRestaurants" }
]
```
### Follow-Up Questions
1. How do I create a compound index in MongoDB Compass or via a shell command?
2. What other fields should I consider adding to my indexes for restaurant lookups?
3. How can I further optimize aggregations when working with larger datasets?

The following examples demonstrate questions you can ask the intelligent assistant about Data Explorer functions and queries.

How is MongoDB data modeling different from data modeling with a relational
database?
MongoDB data modeling differs from relational database (RDBMS) data
modeling in some important ways:
1. Document-Oriented vs. Table-Oriented
- MongoDB stores data as flexible, hierarchical JSON-like documents.
- Relational databases use tables with fixed schemas and columns.
2. Schema Flexibility
- In MongoDB, collections can contain documents with different structures. Schema enforcement is optional.
- RDBMS tables have a strict schema that enforces data types and relationships.
3. Embedding vs. Normalization
- MongoDB encourages embedding related data inside documents when appropriate (denormalization). Example: An order document may include an array of items directly inside it.
- Relational databases emphasize normalization—splitting data across tables connected by foreign keys.
4. Relationships
- MongoDB does support references between documents (similar to foreign keys), but joins are less central and not as efficient as in RDBMS.
- RDBMSs use normalized data and JOIN operations to relate tables efficiently.
5. Performance & Scaling
- MongoDB’s data model enables horizontal scaling (sharding), making it well-suited for large, distributed datasets.
- RDBMS scaling typically relies on vertical scaling or complex clustering; JOINs can become expensive as data grows.
6. Use Cases and Design Philosophy
- MongoDB models are often designed to optimize common query patterns, reducing the need for joins and complex queries.
- RDBMS models are designed for transactional consistency and for representing organized, well-structured relationships.
In summary, MongoDB encourages a more flexible, application-driven
approach to modeling, while relational databases rely on rigid schemas
and normalized relationships. Compass provides tools to visually explore
your document structures and relationships, which can be especially
helpful as your model evolves.
How can I combine multiple conditions in a single $search query?
To combine multiple conditions in a single $search query in MongoDB Atlas
Search (including Compass), you should use the compound operator. The
compound operator allows you to specify multiple criteria using must,
mustNot, filter, and should clauses.
Example: Combine Multiple Conditions
Suppose you want to:
- Match documents where the plot field contains "baseball"
- Exclude documents where the genres field contains "Comedy" or "Romance"
Your $search stage would look like this:
{
"$search": {
"compound": {
"must": [
{
"text": {
"query": "baseball",
"path": "plot"
}
}
],
"mustNot": [
{
"text": {
"query": ["Comedy", "Romance"],
"path": "genres"
}
}
]
}
}
}

Back

Prompt Aggregation

On this page