1. Overview
The Ana x MongoDB integration connects your MongoDB cluster to Ana, giving you natural language access to your collections. MongoDB is a document database, so Ana queries it with native aggregation pipelines (db.<collection>.aggregate([...])) rather than SQL — collections appear as tables, nested document fields are exposed as dot-paths (address.city), and arrays can be $unwind-ed. Results come back as a normal table.
Connect MongoDB to Ana to query and analyze your collections using natural language.
2. Prerequisites
You’ll need:- A MongoDB cluster you want Ana to query — MongoDB Atlas or a self-managed deployment
- A read-only database user, and permission to view the cluster’s connection string
- A TextQL account with permission to add connectors
Which type of connection should I use?
3. Capabilities
Once configured, Ana can:- Query any collection in plain language and return the results as a table.
- Aggregate across documents — group, filter, and summarize without hand-written pipelines.
- Read nested fields as dot-paths and expand arrays where a question needs per-element rows.
- Query across every database in the cluster, or stay scoped to one.
4. Setup Instructions
Step 1: Gather your MongoDB connection details
- MongoDB Atlas
- Self-managed
- Go to cloud.mongodb.com and sign in.
- Navigate to your cluster and click Connect.
- Choose Drivers.
-
Under step 3, MongoDB shows a connection string like:
You need only the host from it — the part between
@and/. In this example that’scluster0.7fmjzec.mongodb.net. Don’t paste the whole string into TextQL. - Note the username, and the password for that database user. Atlas does not show an existing user’s password again — if you don’t have it, reset it under Database Access, or create a new read-only user there.
- Under Network Access, add your TextQL egress IP to the allowlist. See the Network Configuration Guide for the addresses to allow.
Step 2: Add MongoDB as a connector in TextQL
- Go to the TextQL Connectors Page and sign in.
- Click New Connector and select MongoDB.
- Fill in two fields:
- Connector Name — a descriptive name for this connection.
- Host — the host from Step 1, on its own, with no
mongodb+srv://prefix and no trailing path (e.g.cluster0.7fmjzec.mongodb.net).
- For MongoDB Atlas, turn on Use SRV connection (mongodb+srv, for Atlas). For a self-managed deployment, leave it off and enter the deployment’s Port instead.
- Click Create Connector.
Step 3: Verify the connection
- Open the MongoDB connector and click Test Connection.
- A successful setup returns a connection confirmation.
- If the test fails, see the Troubleshooting section below.
5. Usage Examples
Once configured, you can ask Ana:- “How many documents are in the orders collection, and how has that grown by month?”
- “Break down users by the city in their address field.”
- “Which products appear most often across all order line items?”
- “Show me the orders collection’s fields and what types they hold.”
- “Compare average order value between customers acquired this year and last.”
6. Troubleshooting
7. Security Notes
- Follow the principle of least privilege. Grant the connector’s user read access only to the data Ana needs —
readAnyDatabase, orreadon a single database. - Keep Use TLS enabled so credentials and query results are encrypted in transit. Atlas requires it.
- Keep the Atlas Network Access allowlist as narrow as possible rather than opening the cluster to all addresses.
- Credentials are stored encrypted by TextQL. Rotate the database user’s password if you suspect it has been exposed, and update the connector afterwards.
- If you no longer need the integration, remove the connector in TextQL and delete the database user in MongoDB.