# 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

| Properties | Description |
| --- | --- |
| Use existing connection | Select this check box and in the Component<br>List drop-down list, select the desired connection component to<br>reuse the connection details you already defined. |
| DB Version | Select the database version you want to use from the drop-down list.<br><br>This field is available when the Use<br>existing connection check box is not selected. |
| Use connection string | Select this option to establish a connection using a MongoDB<br>Atlas URI. Enter the URI in the field to the right. See [Connection String URI Format](https://docs.mongodb.com/manual/reference/connection-string/) for related information.<br><br>This option is available when you select MongoDB 4.4.X and<br>later from the DB Version drop-down<br>list.<br><br>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<br>address table.<br><br>In the Replica address table, you can define multiple MongoDB database<br>servers for failover.<br><br>This field is available when the<br>Use existing connection check box is<br>not selected. |
| Server and Port | Enter the IP address and listening port of the database server.<br><br>These fields are available when the Use existing connection or Use<br>replica set address check box are not selected. |
| Database | Enter the name of the database. |
| Use SSL connection (Configure the SSL<br>authentication in tSetKeystore or in Studio preferences) | Select this checkbox to enable the SSL or TLS encrypted connection.<br><br>Then you need to use the tSetKeystore<br>component in the same Job to specify the encryption information.<br><br>Note that the SSL connection is available only for the version 2.4 + of<br>MongoDB. |
| Set read preference | Select this check box and from the Read preference<br>drop-down list that is displayed, select the member to which you need to direct the read<br>operations.<br><br>If you leave this check box clear, the Job uses the default Read preference, that is to<br>say, uses the primary member in a replica set.<br><br>For further information, see MongoDB's documentation about Replication and its Read<br>preferences. |
| Required authentication | Select this check box to enable the database authentication.<br><br>Among the mechanisms listed on the Authentication mechanism<br>drop-down list, the NEGOTIATE one is recommended if<br>you are not using Kerberos, because it automatically select the authentication mechanism<br>the most adapted to the MongoDB version you are using.<br><br>Because the SCRAM-SHA-256 authentication mechanism is only supported by<br>MongoDB 4.x and later versions, SCRAM-SHA-256 SASL option is available<br>only when MongoDB 4.4.X and later is selected from the DB<br>Version drop-down list.<br><br>Information noteNote: The X509 option is available only when you have<br>installed the R2021-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.<br><br>For details about the other mechanisms in this list, see [MongoDB Authentication](https://docs.mongodb.org/manual/reference/parameters/#param.authenticationMechanisms) from the MongoDB<br>documentation. |
| Set Authentication database | If the username to be used to connect to MongoDB has been created in a specific<br>Authentication database of MongoDB, select this check box to enter the name of this<br>Authentication database in the Authentication database<br>field that is displayed.<br><br>For further information about the MongoDB Authentication database, see [User Authentication database](https://docs.mongodb.org/manual/core/security-users/#user-authentication-database). |
| Username and Password | Enter the database user authentication data.<br><br>To enter the password, click the [...] button<br>next to the password field, enter the password in double quotes in the pop-up dialog box,<br>and click OK to save the settings.<br><br>This field is available when the Required authentication check box is<br>selected.<br><br>If the security system you have selected from the Authentication mechanism dropdown list is Kerberos, you need to<br>enter the User principal, the Realm and the KDC<br>server fields instead of the Username and the Password<br>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<br>(columns) to be processed and passed on to the next component. When you create a Spark<br>Job, avoid the reserved word line when naming the<br>fields.<br><br>Click Edit<br>schema to make changes to the schema. If the current schema is of the Repository type, three options are available:<br><br><ul> <li> <p> <span>View schema</span>: choose this                option to view the schema only.</p> </li> <li> <p> <span>Change to built-in property</span>:                choose this option to change the schema to <span>Built-in</span> for local changes.</p> </li> <li> <p> <span>Update repository connection</span>:                choose this option to change the schema stored in the repository and decide whether                to propagate the changes to all the Jobs upon completion.</p> <p>If you just want to                propagate the changes to the current Job, you can select <span>No</span> upon completion and choose this schema metadata                again in the <span>Repository Content</span>                window.</p> </li> </ul><br><br>If a column in the database is a JSON document and you need to read<br>the entire document, put an asterisk (\*) in the DB<br>column column, without quotation marks around. |
| Query | Specify the query condition. This field is available only when you have<br>selected Find query from the Query type drop-down list.<br><br>For<br>example, type in "{id:4}" to retrieve the<br>record whose *id* is *4* from the<br>collection specified in the Collection<br>field.<br><br>Information noteNote:<br><br>Different from the query statements required in the MongoDB<br>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<br>returned from the database |
| Return only these fields | Enter the name of the fields to be returned from the data in this<br>table.<br><br>This field is only available when you check the Specify<br>fields to return from the Basic settings<br>view. |
| Aggregation stages | Create a MongoDB aggregation pipeline by adding the stages you want the<br>documents to pass through so as to obtain aggregated results from these documents.<br>This table is available only when you have selected Aggregation pipeline query from the Query type drop-down list.<br><br>Only one stage is<br>allowed per row in this Aggregation<br>stages table and the stages are executed one by one in the order<br>you place them in this table. For more information about MongoDB aggregation<br>pipeline, see [Aggregation pipeline](https://docs.mongodb.org/manual/core/aggregation-pipeline/).<br><br>Example 1:<br><br><ul> <li> <div>If you want to aggregate documents about your customers using the <em>$match</em> and the <em>$group</em>                              stages, you need to add two rows to this <span>Aggregation stages</span> table and define the two stages as                              follows:<pre><code><pre><code><code>"{$match : {status : 'A'}}""{$group : {_id : '$cust_id', total : {$sum : '$amount'}}}"</code></code></pre></code></pre> </div> <p>In this aggregation, the customer documents with                              status <kbd>A</kbd> are selected; then among the selected                              customers, those using the same customer ID are grouped and the values                              from the <kbd>amount</kbd> fields of the same customer are                              summed up.</p> <p>For a full list of the stages you can use and their                              related operators, see <a href="https://docs.mongodb.org/manual/reference/operator/aggregation/#aggregation-pipeline-operator-reference" target="_blank">Aggregation pipeline                                 operators</a>.</p> </li> </ul><br><br>Example 2:<br><br><ul> <li> <div>This component supports <a href="https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/" target="_blank">Atlas Vector Search</a>                              capabilities, you can use this option to query data using the                              $vectorSearch aggregation stage, and a vector search index previously                              created using a <a href="https://help.qlik.com/talend/en-US/components/8.0/mongodb/tmongodbrow#tmongodbrow-standard-properties" target="_blank">tMongoDBRow</a>                              component:<pre><code><pre><code><code>"{$vectorSearch : {index : '&lt;index_name&gt;', path : '&lt;field_to_search&gt;', queryVector:"[&lt;array_of_numbers&gt;], numCandidates: &lt;number_of_candidates&gt;, limit: &lt;number_of_results&gt;}}}" </code></code></pre></code></pre> </div>For                           more information on the $vectorSearch query parameters, see <a href="https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/" target="_blank">the corresponding MongoDB                              documentation</a>.</li> </ul> |
| Mapping | Each column of the schema defined for this component represents a field of the documents<br>to be read. In this table, you need to specify the parent nodes of these fields, if<br>any.<br><br>For example, in the document reading as<br>follows<br><br>```<br>{<br>_id: ObjectId("5099803df3f4948bd2f98391"),<br>person: { first: "Joe", last: "Walker" }<br>}<br>```<br><br><br>The<br>*first* and the *last*<br>fields have *person* as their parent node but the *\_id* field does not have any parent node. So once completed, this<br>Mapping table should read as<br>follows:<br><br>```<br>Column     Parent node path<br>_id<br>first       "person"<br>last        "person"<br>``` |
| Sort by | Specify the column and choose the order for the sort operation.<br><br>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.<br><br>This field is available only when you have selected Find query from the Query<br>type drop-down list. |
| Skip | Specify the number of the retrieved lines to skip. Note that lines are<br>skipped from the first line.<br><br>Information noteNote: This option is available only when you have<br>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<br>avoid possible errors, do not set this option to<br>1.<br><br>Information noteNote: This option is available only when you have<br>installed the R2022-01 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator. |

## Advanced settings

| Properties | Description |
| --- | --- |
| tStatCatcher Statistics | Select this check box to collect the log data at the component<br>level. |
| No query timeout | Select this check box to prevent MongoDB servers from stopping idle<br>cursors at the end of 10-minute inactivity of these cursors. In this<br>situation, an idle cursor will stay open until either the results of<br>this cursor are exhausted or you manually close it using the<br>cursor.close() method.<br><br>A cursor for MongoDB is a pointer to the result set of a query. By<br>default, that is to say, with this check box being clear, a MongoDB<br>server automatically stops idle cursors after a given inactivity period<br>to avoid excess memory use. For further information about MongoDB<br>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<br>values for array type are then basic object list.<br><br>This option is only<br>available for MongoDB 3.5.x, 4.4.x and later versions. |

## Global Variables

| Variables | Description |
| --- | --- |
| Global Variables | NB\_LINE: the number<br>of rows read by an input component or transferred to an output component. This is an<br>After variable and it returns an integer.<br><br><br>ERROR\_MESSAGE: the error message generated by the<br>component when an error occurs. This is an After variable and it returns a string. This<br>variable functions only if the Die on error checkbox is<br>cleared, if the component has this checkbox.<br><br>A Flow variable functions during the execution of a component<br>while an After variable functions after the execution of the component.<br><br>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<br>it.<br><br>For more information about variables, see [Using contexts and variables](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/contexts-and-variables). |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | As a start component, tMongoDBInput<br>allows you to retrieve records from a collection in the MongoDB database and<br>transfer them to the following component for display or storage. |