Natural Language Queries
Agent M's AI understands natural language, making MongoDB queries accessible to everyone. Learn how to communicate effectively with AI to get the results you need.
How It Works
Instead of writing MongoDB syntax like:
db.users.find({age: {$gte: 18}, city: "New York"})
You can simply say:
The AI translates your natural language into proper MongoDB queries and explains what it does.
Basic Query Patterns
The beauty of Agent M lies in how it translates your natural language into MongoDB queries. When you want to find documents, you can start simple with "Show me all users" and the AI creates db.users.find()
to return all documents in the users collection.
Counting and Aggregation
When you need to count documents, simply ask "How many products do we have?" and the AI creates db.products.countDocuments()
to return the total number of products.
Sorting and Limiting
Sort Results
- You say: "Show me the most expensive products"
- AI creates:
db.products.find().sort({price: -1})
- Result: Products sorted by price (highest first)
Limit Results
- You say: "Get the top 10 users by registration date"
- AI creates:
db.users.find().sort({createdAt: -1}).limit(10)
- Result: 10 most recently registered users
Advanced Query Patterns
Date and Time Queries
Recent Data
- You say: "Show me orders from the last 7 days"
- Result: Orders from the past week
Date Range
- You say: "Find users registered between January and March"
- Result: Users registered in Q1
Text Search
Contains Text
- You say: "Find products with 'laptop' in the name"
- Result: Products with "laptop" in the name
Exact Match
- You say: "Get users with email ending in @gmail.com"
- Result: Users with Gmail addresses
Tips for Better Queries
Be Specific and Clear
❌ Vague
✅ Specific
Mention Collection Names
❌ Ambiguous
✅ Clear
Next Steps
Conversation Management
Learn how to organize multiple query sessions, maintain context across conversations, and efficiently manage your AI interactions.
Understanding Query Results
Master different result views, learn how to interpret AI responses, and efficiently work with query outputs in various formats.