Skip to main content Skip to complementary content

tMongoDBInput Standard properties

These properties are used to configure tMongoDBInput running in the Standard Job framework.

The Standard tMongoDBInput component belongs to the Big Data and the Databases NoSQL families.

The component in this framework is available in all Talend products with Big Data and in Talend Data Fabric.

Basic settings

Use existing connection

Select this check box and in the Component List drop-down list, select the desired connection component to reuse the connection details you already defined.

DB Version

Select the database version you want to use from the drop-down list.

This field is available when the Use existing connection check box is not selected.

Use connection string

Select this option to establish a connection using a MongoDB Atlas URI. Enter the URI in the field to the right. See Connection String URI Format for related information.

This option is available when you select MongoDB 4.4.X and later from the DB Version drop-down list.

Information noteNote: This option is available only when you have installed the R2021-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.

Use replica set address

Select this check box to show the Replica address table.

In the Replica address table, you can define multiple MongoDB database servers for failover.

This field is available when the Use existing connection check box is not selected.

Server and Port

Enter the IP address and listening port of the database server.

These fields are available when the Use existing connection or Use replica set address check box are not selected.

Database

Enter the name of the database.

Use SSL connection (Configure the SSL authentication in tSetKeystore or in Studio preferences)

Select this check box to enable the SSL or TLS encrypted connection.

Then you need to use the tSetKeystore component in the same Job to specify the encryption information.

Note that the SSL connection is available only for the version 2.4 + of MongoDB.

Set read preference

Select this check box and from the Read preference drop-down list that is displayed, select the member to which you need to direct the read operations.

If you leave this check box clear, the Job uses the default Read preference, that is to say, uses the primary member in a replica set.

For further information, see MongoDB's documentation about Replication and its Read preferences.

Required authentication

Select this check box to enable the database authentication.

Among the mechanisms listed on the Authentication mechanism drop-down list, the NEGOTIATE one is recommended if you are not using Kerberos, because it automatically select the authentication mechanism the most adapted to the MongoDB version you are using.

Because the SCRAM-SHA-256 authentication mechanism is only supported by MongoDB 4.x and later versions, SCRAM-SHA-256 SASL option is available only when MongoDB 4.4.X and later is selected from the DB Version drop-down list.

Information noteNote: The X509 option is available only when you have installed the R2021-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.

For details about the other mechanisms in this list, see MongoDB Authentication from the MongoDB documentation.

Set Authentication database

If the username to be used to connect to MongoDB has been created in a specific Authentication database of MongoDB, select this check box to enter the name of this Authentication database in the Authentication database field that is displayed.

For further information about the MongoDB Authentication database, see User Authentication database.

Username and Password

Enter the database user authentication data.

To enter the password, click the [...] button next to the password field, enter the password in double quotes in the pop-up dialog box, and click OK to save the settings.

This field is available when the Required authentication check box is selected.

If the security system you have selected from the Authentication mechanism drop-down list is Kerberos, you need to enter the User principal, the Realm and the KDC server fields instead of the Username and the Password fields.

Collection

Enter the name of the collection in the MongoDB database.

Schema and Edit Schema

A schema is a row description. It defines the number of fields (columns) to be processed and passed on to the next component. When you create a Spark Job, avoid the reserved word line when naming the fields.

Click Edit schema to make changes to the schema. If the current schema is of the Repository type, three options are available:

  • View schema: choose this option to view the schema only.

  • Change to built-in property: choose this option to change the schema to Built-in for local changes.

  • Update repository connection: choose this option to change the schema stored in the repository and decide whether to propagate the changes to all the Jobs upon completion.

    If you just want to propagate the changes to the current Job, you can select No upon completion and choose this schema metadata again in the Repository Content window.

If a column in the database is a JSON document and you need to read the entire document, put an asterisk (*) in the DB column column, without quotation marks around.

Query

Specify the query condition. This field is available only when you have selected Find query from the Query type drop-down list.

For example, type in "{id:4}" to retrieve the record whose id is 4 from the collection specified in the Collection field.

Information noteNote:

Different from the query statements required in the MongoDB client software, the query here refers to the contents inside find(), such as the query here {id:4} versus the MongoDB client query db.blog.find({id:4}).

Specify fields to return

Select this check box to define a set of fields in the documents to be returned from the database

Return only these fields

Enter the name of the fields to be returned from the data in this table.

This field is only available when you check the Specify fields to return from the Basic settings view.

Aggregation stages

Create a MongoDB aggregation pipeline by adding the stages you want the documents to pass through so as to obtain aggregated results from these documents. This table is available only when you have selected Aggregation pipeline query from the Query type drop-down list.

Only one stage is allowed per row in this Aggregation stages table and the stages are executed one by one in the order you place them in this table.

For example, if you want to aggregate documents about your customers using the $match and the $group stages, you need to add two rows to this Aggregation stages table and define the two stages as follows:
"{$match : {status : 'A'}}"
"{$group : {_id : '$cust_id', total : {$sum : '$amount'}}}"

In this aggregation, the customer documents with status A are selected; then among the selected customers, those using the same customer id are grouped and the values from the amount fields of the same customer are summed up.

For a full list of the stages you can use and their related operators, see Aggregation pipeline operators.

For more information about MongoDB aggregation pipeline, see Aggregation pipeline.

Mapping

Each column of the schema defined for this component represents a field of the documents to be read. In this table, you need to specify the parent nodes of these fields, if any.

For example, in the document reading as follows
{
               _id: ObjectId("5099803df3f4948bd2f98391"),
               person: { first: "Joe", last: "Walker" }
            }
The first and the last fields have person as their parent node but the _id field does not have any parent node. So once completed, this Mapping table should read as follows:
Column     Parent node path
_id
first       "person"
last        "person"

Sort by

Specify the column and choose the order for the sort operation.

This field is available only when you have selected Find query from the Query type drop-down list.

Limit

Type in the maximum number of records to be retrieved.

This field is available only when you have selected Find query from the Query type drop-down list.

Skip

Specify the number of the retrieved lines to skip. Note that lines are skipped from the first line.

Information noteNote: This option is available only when you have installed the R2022-01 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.

Batch size

Specify the maximum number of lines that can be retrieved in one batch. To avoid possible errors, do not set this option to 1.

Information noteNote: This option is available only when you have installed the R2022-01 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.

Advanced settings

tStatCatcher Statistics

Select this check box to collect the log data at the component level.

No query timeout

Select this check box to prevent MongoDB servers from stopping idle cursors at the end of 10-minute inactivity of these cursors. In this situation, an idle cursor will stay open until either the results of this cursor are exhausted or you manually close it using the cursor.close() method.

A cursor for MongoDB is a pointer to the result set of a query. By default, that is to say, with this check box being clear, a MongoDB server automatically stops idle cursors after a given inactivity period to avoid excess memory use. For further information about MongoDB cursors, see https://docs.mongodb.org/manual/core/cursors/.

Convert BSON document to string

Select this check box to convert all values in BSON to string. The values for array type are then basic object list.

This option is only available for MongoDB 3.5.x, 4.4.x and later versions.

Global Variables

Global Variables

NB_LINE: the number of rows read by an input component or transferred to an output component. This is an After variable and it returns an integer.

ERROR_MESSAGE: the error message generated by the component when an error occurs. This is an After variable and it returns a string. This variable functions only if the Die on error check box is cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl+Space to access the variable list and choose the variable to use from it.

For more information about variables, see Using contexts and variables.

Usage

Usage rule

As a start component, tMongoDBInput allows you to retrieve records from a collection in the MongoDB database and transfer them to the following component for display or storage.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!