The MongoDB extractor allows you to fetch data from the NoSQL MongoDB database. Complete the following steps to configure it.
Find MongoDB in the Extractors section. Create a new configuration and name it.
Click Setup Database Credentials and fill in the form. Then test the new credentials and save them. Optionally, set up an SSH tunnel.
Click the Add Export button and configure your first export using the following options:
Name – Identifies your export; its value has to be unique across all exports and exported tables in your configuration. Also, the main exported table will be named after the value of the Name field.
Collection – Represents the collection name in your MongoDB database.
Query (optional) – JSON string specifying a query which limits documents data in exported data. Must be specified in a strict format.
Sort (optional) – JSON string specifying the order of documents in exported data. Must be specified in a strict format.
Limit (optional) – Limits the number of exported documents.
Incremental – Loads data to your tables incrementally.
Mode – Specifies the export mode: Mapping or Raw.
Mapping – This is the most important section in case you have selected the Mapping mode; it defines how documents in the collection are mapped to the output tables. It, too, has to be valid JSON.
Tip: Use a combination of a limit (for example, only 10 documents) and a query (for example, only a document with specific ID) while playing with the mapping section to prevent a full collection export.
By defining mapping, you specify the structure and content of your output tables, their columns and relations between them.
Since MongoDB identifies each document in a collection uniquely by
_id, we recommend to set
a primary key to this field by defining the first item in a mapping section:
Note: The destination column with the primary key should be named
_id to prevent problems with
the data import.
To handle MongoDB data types correctly, define mapping similarly to the following example for
NumberLong data types:
Check out more mapping examples.
In the raw export mode, documents are exported as plain JSON strings.
Having successfully mapped the configuration, run the extractor by hitting the Run Extraction button.