Natural language to MongoDB query generation
Parent: MongoDB Query Optimization Tooling: Compass Explain, Atlas Query Insights and Performance Advisor · Published reference · snapshot 2026-10-22 · skill ranked-c1db2bdc
↓ Facts as markdownall context files
Source-anchored research for Natural language to MongoDB query generation. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Structure and components
- MongoDB's manual lists Compass Natural Language Querying and Atlas UI Natural Language Querying as tools for generating MongoDB queries from natural language. In Atlas, prompts can produce filter queries or aggregation pipelines. MongoDB describes the result as a starting point, labels the feature experimental and potentially inaccurate, and tells users to review the generated syntax before execution. Atlas asks for confirmation before running pipelines that contain data-changing operators such as $merge or $out. (high confidence) (verified as of 2026-10-14) [source]
How it works
- Atlas Data Explorer can generate a filter query from the Documents tab or an aggregation pipeline from the Aggregations tab. Atlas places the output in the query or pipeline bar and instructs users to review its syntax before running it; pipelines containing $merge or $out require confirmation because they can modify collection data. (high confidence) [source]
Measurements and reference values
- Published accuracy figures are tied to each study's workload and evaluation method. The 2025 DocSpider paper reports GPT-4o execution accuracy of 71.0% zero-shot and 81.1% after fine-tuning on DocSpider; its authors say errors were more common for uncommon syntax such as NOT IN and regular expressions. A 2024 RIT capstone reports 75.18% overall on a WikiSQL-derived dataset that excluded joins and used recursive structural equality to score queries. These results are not directly comparable. (medium confidence) [source]
- The AptMQL-Bench v1 preprint submitted on 2026-10-02 reports 57.38% accuracy for Claude Opus 4.5 without external evidence and 70.34% with evidence, across 21 MongoDB document databases and 3,186 natural-language requests. The authors characterize realistic text-to-MQL generation as challenging. (low confidence) (verified as of 2026-10-02) [source]
- The EvoMQL v1 preprint submitted on 2026-03-11 builds query-aware evidence contexts and uses execution-based rewards in iterative draft, refine, and optimize cycles. It reports 76.6% execution accuracy on the EAI in-distribution benchmark and 83.1% on the TEND out-of-distribution benchmark; these are results for those named benchmarks. (low confidence) (verified as of 2026-03-11) [source]
- The AptMQL-Bench preprint reports that heuristic migrations which mirrored relational schemas and queries failed to migrate 6 of 21 BIRD databases and silently dropped up to 25.9% of rows in others. The authors instead design document schemas from access patterns and rewrite queries to MongoDB-native forms, which cautions against treating relational-to-document conversion as a neutral generation baseline. (low confidence) (verified as of 2026-10-02) [source]
Facts and statements
- MongoDB's general NL-to-MongoDB guide recommends a clear task and output contract, annotated collection schemas, representative sample documents, and index information; it also recommends supplying the current date for time-relative requests. A 2024 Rochester Institute of Technology capstone represents each training example with a schema, natural-language question, and MongoDB query. A 2026 implementation write-up infers schema from sampled collections and loads domain relationship documentation before generation. (high confidence) [source]
- As of 2026-10-14, MongoDB documents say Atlas natural-language querying uses Azure OpenAI as its current provider, which may change, and sends prompts and schema details to Microsoft and OpenAI for processing. MongoDB says that this data is not stored on third-party storage systems or used to train AI models; the docs also say feature availability follows a rolling release. (medium confidence) (verified as of 2026-10-14) [source]
- Natural-language-to-MQL generation maps a prose request, together with collection context, into a MongoDB filter query or aggregation pipeline. MongoDB describes generated queries as a useful starting point and warns that generative output may be inaccurate, so reviewers should verify fields, operators, and stages against the requested result before execution. (high confidence) [source]
- Prompt quality depends on database context and output constraints. MongoDB recommends specifying the target query form, supplying collection schemas with field meanings and types, adding sample documents and index information, and spelling out edge cases such as arrays, dates, null values, and missing fields. Its benchmark reports that sample documents and annotated schemas can improve generation in its tested settings, while automatically interpreted schemas can hurt less capable models. (medium confidence) [source]
- Research studies use different data construction and evaluation setups, so their accuracy figures should be read within each benchmark. Oza's 2024 RIT project converts WikiSQL data and excludes join queries; DocSpider builds Spider-derived natural-language/MQL pairs and manually corrects some outputs; AptMQL-Bench designs MongoDB schemas around access patterns and rewrites queries for the document model. (medium confidence) [source]
- Benchmark correctness should cover execution semantics, not only syntax. DocSpider evaluates whether generated MQL returns the same rows as the reference SQL, manually fixes some projection and sorting mismatches in its training data, and reports more errors for less common NOT IN and regular-expression cases. MongoDB's benchmark separately tracks successful execution, output matching, nonempty and reasonable results, and query time, but says its execution-time measurements were unreliable in that environment. (medium confidence) [source]
Children
- Schema grounding and value linking for MQL generation (frontier)
- Execution-guided text-to-MQL refinement (frontier)
- Validation and performance review of generated queries (frontier)
Frontier under this node: Execution-guided text-to-MQL refinement, Schema grounding and value linking for MQL generation, Validation and performance review of generated queries