Database
MongoDB Connector
Index the collections of a MongoDB database, sub-documents flattened into readable field paths.
Prerequisites
- A MongoDB database you can read, version 4.4 or later
- A user with the `read` role on that database
- A connection string, or the host, port and database name
Data ingested
When you connect MongoDB, the following content becomes searchable. Every answer that uses it cites it.
| Content | What is kept |
|---|---|
| Collections | Every collection of the database, one document per collection. System collections are skipped |
| Documents | Up to 500 documents per collection, each rendered as a flat field list |
| Sub-documents | Flattened into dotted paths: `fournisseur.nom`, `adresse.ville` |
Setup
Configuration happens in the dashboard, under Integrations. No API call is needed for a normal setup.
Create a read-only user
`db.createUser({user: 'qm_reader', pwd: '...', roles: [{role: 'read', db: 'mydb'}]})`. The `read` role is enough: the connector never writes.
Enter the connection
Integrations → Add source → MongoDB: the connection string in the **URL** field, or host, port (27017 by default) and database.
Set the secret
The password, unless the connection string already carries it. Add `?authSource=admin` when the user is defined on the `admin` database.
Connect and sync
**Test** lists the collections without indexing; **Sync** reads the documents and indexes them.
Configuration options
| Field | Description | Required |
|---|---|---|
| URL or DSN | Full `mongodb://user:password@host:port/database`. Takes precedence over the separate fields | No |
| Host | Database host. Defaults to `127.0.0.1` | No |
| Port | Database port. Defaults to `27017` | No |
| Database | Name of the database to index | Yes |
| User | User used to connect | Yes |
| Secret | Password of that user | No |
| Schema | Not used by MongoDB: collections are already scoped to the database | No |
Best practices
- •MongoDB documents are heterogeneous: the connector unions the fields of every document read, so a field missing from some documents still appears as a column.
- •Index a read replica or a secondary rather than the primary when the collection is large: a sync reads up to 500 documents per collection.
- •System collections (`system.*`) are skipped automatically. There is nothing to exclude by hand.
Troubleshooting
The user is often defined on the `admin` database: add `?authSource=admin` to the connection string, or use a user created on the target database.
The **Database** field is empty. MongoDB cannot list collections without a database name.
A collection with no document yields no readable content and is reported as empty rather than silently skipped.
The server is reachable but the IP is not in `bindIp`. Check `net.bindIp` in `mongod.conf`, and open the port in the firewall.
Next steps
Once the source is connected and indexed, ask a question from the chat and check that the answer cites this source. A source that never appears in a citation is usually a source with nothing indexed: see Troubleshooting above.
