Hostname: page-component-76d6cb85b7-jhrpq Total loading time: 0 Render date: 2026-07-16T01:43:57.045Z Has data issue: false hasContentIssue false

DocSpider: a dataset of cross-domain natural language querying for MongoDB

Published online by Cambridge University Press:  12 February 2025

Arif Görkem Özer*
Affiliation:
Computer Engineering, Middle East Technical University, Ankara, Türkiye
Recep Firat Cekinel
Affiliation:
Computer Engineering, Middle East Technical University, Ankara, Türkiye
Ismail Hakki Toroslu
Affiliation:
Computer Engineering, Middle East Technical University, Ankara, Türkiye
Pinar Karagoz
Affiliation:
Computer Engineering, Middle East Technical University, Ankara, Türkiye
*
Corresponding author: Arif Görkem Özer; Email: gorkem@ceng.metu.edu.tr
Rights & Permissions [Opens in a new window]

Abstract

Natural language querying allows users to formulate questions in a natural language without requiring specific knowledge of the database query language. Large language models have been very successful in addressing the text-to-SQL problem, which is about translating given questions in textual form into SQL statements. Document-oriented NoSQL databases are gaining popularity in the era of big data due to their ability to handle vast amounts of semi-structured data and provide advanced querying functionalities. However, studies on text-to-NoSQL systems, particularly on systems targeting document databases, are very scarce. In this study, we utilize large language models to create a cross-domain natural language to document database query dataset, DocSpider, leveraging the well-known text-to-SQL challenge dataset Spider. As a document database, we use MongoDB. Furthermore, we conduct experiments to assess the effectiveness of the DocSpider dataset to fine-tune a text-to-NoSQL model against a cross-language transfer learning approach, SQL-to-NoSQL, and zero-shot instruction prompting. The experimental results reveal a significant improvement in the execution accuracy of fine-tuned language models when utilizing the DocSpider dataset.

Information

Type
Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2025. Published by Cambridge University Press
Figure 0

Figure 1. Natural language querying problem.

Figure 1

Figure 2. The pipeline overview.

Figure 2

Figure 3. The proposed dataset construction and evaluation pipeline.

Figure 3

Figure 4. Prompt engineering for MQL query generation.

Figure 4

Table 1. Number of ground-truth queries generated by language models

Figure 5

Figure 5. Difficulty level distribution of the queries in the data splits.

Figure 6

Table 2. Zero-shot execution accuracy percentages

Figure 7

Figure 6. Prompt template used in the experiments.

Figure 8

Table 3. Text-to-SQL-to-NoSQL execution accuracy percentages

Figure 9

Table 4. Fine-tuning execution accuracy percentages

Figure 10

Table 5. The average cosine similarity values for correct and incorrect MQLs for fine-tuned models

Figure 11

Figure 7. Fine-tuning train-val loss graphs.