Documentation

AI Assistant

AI Assistant

Use AI to generate MongoDB queries, build aggregation pipelines, and analyze your database schema. Describe what you need in plain English and let AI write the MongoDB code for you.

Quick Start

Generate your first AI-powered query:

  1. Click the AI Assistant button in the toolbar or sidebar
  2. Select your target collection
  3. Type your request in plain English (e.g., "Find all users who signed up this month")
  4. Review the generated MongoDB query
  5. Click "Use Query" to apply it to the Query Builder or Shell
AI Assistant interface showing chat panel and generated query

AI Query Generation

Generate MongoDB find queries from natural language descriptions. Perfect for complex filters, date ranges, and multi-condition queries.

AI generating a MongoDB query from natural language input

Query Examples

Natural Language Generated Query
"Find users with verified email" { emailVerified: true }
"Get orders over $100 from last week" { total: { $gt: 100 }, createdAt: { $gte: ISODate("...") } }
"Find products with stock less than 10" { stock: { $lt: 10 } }
"Show customers from New York or California" { state: { $in: ["NY", "CA"] } }

Query Generation Features

  • Schema-Aware: AI understands your collection schema and suggests valid field names
  • Date Handling: Automatically converts date references like "last month" or "this year"
  • Operator Selection: Chooses appropriate operators ($gt, $lt, $in, $regex, etc.)
  • Nested Fields: Supports queries on nested document fields
  • Array Queries: Handles array field queries with $elemMatch, $all, etc.

AI Aggregation Pipelines

Build complex aggregation pipelines by describing your data transformation in plain English.

AI generating a multi-stage aggregation pipeline

Aggregation Examples

Natural Language Generated Pipeline
"Total sales by category" $group by category, $sum sales
"Top 10 customers by order count" $group by customer, $count, $sort desc, $limit 10
"Average order value per month" $group by month, $avg orderValue
"Join orders with customer details" $lookup from customers

Aggregation Features

  • Multi-Stage Pipelines: Generates complete pipelines with multiple stages
  • Stage Optimization: Orders stages for optimal performance (e.g., $match before $group)
  • Accumulator Selection: Chooses appropriate accumulators ($sum, $avg, $max, $min, etc.)
  • $lookup Support: Automatically configures joins between collections
  • Explain Output: Provides explanations for each generated stage

AI Schema Analysis

Get AI-powered insights into your database schema, including field types, data patterns, and optimization recommendations.

AI schema analysis showing field insights and recommendations

Schema Analysis Features

  • Field Type Detection: Identifies field types and shows distribution
  • Pattern Recognition: Detects data patterns (emails, URLs, dates, etc.)
  • Relationship Detection: Finds potential relationships between collections
  • Anomaly Detection: Flags inconsistent field types or unusual values
  • Index Suggestions: Recommends indexes based on schema structure

Schema Insights

Insight Type Description
Field Summary Human-readable summary of each field's purpose and content
Data Quality Percentage of documents with null/missing fields
Relationships Detected foreign key relationships to other collections
Optimization Tips Suggestions for improving schema design

Conversational Context

The AI Assistant maintains conversation context, allowing you to refine queries through follow-up requests.

Conversation Examples

  • User: "Find all orders from last month"
  • AI: Generates query with date filter
  • User: "Only show orders over $50"
  • AI: Adds total > 50 condition to existing query
  • User: "Sort by date descending"
  • AI: Adds sort stage

Using Generated Code

Apply AI-generated queries directly to VisuaLeaf's query tools.

Apply Options

  • Use in Query Builder: Opens the Visual Query Builder with the generated query pre-loaded
  • Use in Aggregation: Opens the Aggregation Pipeline Builder with generated stages
  • Copy to Shell: Copies the MongoDB shell command to clipboard
  • Execute Directly: Run the query immediately and view results
  • Save Query: Save to your query library for future use

AI Settings

Configure AI Assistant behavior and preferences.

AI Settings panel showing configuration options for AI Assistant
Setting Description Default
Schema Context Include collection schema in AI requests for better accuracy Enabled
Sample Documents Number of sample documents to include for context 5
Explain Output Include explanations with generated code Enabled
Auto-Execute Automatically run generated queries (with confirmation) Disabled

Privacy & Security

Your data privacy is important to us:

  • Schema Only: By default, only schema metadata is sent to AI—not your actual data
  • Sample Opt-In: You control whether sample documents are included
  • No Storage: Conversations are not stored on external servers
  • Local Processing: Query execution happens locally on your machine

Pro Tips

  1. Be Specific: Include field names when you know them for more accurate results.
  2. Use Examples: "Like this: {status: 'active'}" helps AI understand your intent.
  3. Iterate: Start simple and refine through conversation.
  4. Review Output: Always review generated queries before executing on production data.
  5. Learn Syntax: Use AI-generated queries as a learning tool for MongoDB syntax.

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial