# tCosmosDBInput

Retrieves certain documents from a Cosmos database collection by supplying a query document containing the fields the desired documents should match.

This component is not shipped with your Talend Studio by default. You need to install it using the Feature Manager. For more information, see [Installing features using the Feature Manager](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/install-features-to-talend-studio).

## tCosmosDBInput Standard properties

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

The Standard tCosmosDBInput component belongs to the Cloud and the Databases 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. |
| API | Select the database API to be used. Then the corresponding parameters to be defined are displayed in the Component view.<br><br>In the current version of this component, only the MongoDB API is supported. For this reason, MongoDB database is often mentioned in the documentation of the CosmosDB components. |
| Use replica set address or multiple query routers | Select this check box to show the Server<br>addresses table.<br><br>In the Server addresses<br>table, define the shared MongoDB databases or the MongoDB replica sets<br>you want to connect to. |
| Server and Port | Enter the IP address and listening port of the database<br>server.<br><br>Available when the Use replica set<br>address or multiple query routers check box is not<br>selected. |
| Database | Enter the name of the MongoDB database to be connected to. |
| 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. |
| Authentication mechanism | 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>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 | DB 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>Available when the Use<br>authentication check box is 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 | Name of the collection in the database. |
| Schema and Edit<br>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<br>have selected Find query from the<br>Query type drop-down list.<br><br>For example, type in "{id:4}" to retrieve the record<br>whose id is 4 from the collection specified in the Collection field.<br><br>Different from the query statements required in the MongoDB client<br>software, the query here refers to the contents inside<br>find(), such as the query here {id:4}<br>versus the MongoDB client query<br>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 fields<br>to return from the Basic settings<br>view. |
| 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 type drop-down list. |

## 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/. |

## Usage

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