Setting up the Job - Cloud - 8.0

MongoDB

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Open Studio for Big Data
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Data Governance > Third-party systems > NoSQL components > MongoDB components
Data Quality and Preparation > Third-party systems > NoSQL components > MongoDB components
Design and Development > Third-party systems > NoSQL components > MongoDB components

Procedure

  1. Double-click tMongoDBConnection_1 to open its Basic settings view and enter all the information that is needed to establish the MongoDB connection.
  2. Double-click tFixedFlowInput_1 to open its Basic settings view and do the following.
    1. Click [...] next to Edit schema and add these columns to the schema: _id, type String; name, type String; address, type String; age, type Integer; and birth, type Date and date pattern "yyyy-MM-dd".
    2. Select Use Inline Table and enter the following in the Inline Table field.
      "101" "name1" "beijing" 21 2017-01-11
      "102" "name2" "shanghai" 22 2017-01-12
    3. Leave other options as they are.
    This component defines the record fields and defines two records for the scenario.
  3. Double-click tMongoDBOutput_1 to open its Basic settings view and do the following.
    1. Select Use existing connection and select tMongoDBConnection_1 from the Component List drop-down list.
    2. Enter the name of the collection (TDI44990_1 in this scenario) to write the records in in the Collection field.
    3. Select Insert from the Action on data drop-down list.
    4. Click the Sync columns button to make sure the schema of this component has the same columns as those of the tFixedFlowInput component.
      Check that the Mapping table has the same columns as those of the tFixedFlowInput component.
    5. Leave other options as they are.
    This component inserts the records to the collection named TDI44990_1.
  4. Double-click tMongoDBInput_2 to open its Basic settings view and do the following.
    1. Select Use existing connection and select tMongoDBConnection_1 from the Connection drop-down list.
    2. Enter the name of the collection (TDI44990_1 in this scenario) to retrieve the records from in the Collection field.
    3. Click [...] next to Edit schema to open the schema editor and add a column with the column name of doc, DB Column of *, and Type of String.
    4. Enter "{name:/^name1/}" in the Query field.
    5. Leave other options as they are.
    This component retrieves the record with the name field being name1 as a string from the TDI44990_1 collection.
  5. Double-click tLogRow_4 to open its Basic settings view and do the following.
    1. Click the Sync column button and then check that the component has the same column in the schema as that of the tMongoDBInput_2 component.
    2. Select the Table (print values in cells of a table) option.
    Note: All the tLogRow components in this scenario take the same configuration.
  6. Double-click tMongoDBOutput_2 to open its Basic settings view and do the following.
    1. Select Use existing connection and select tMongoDBConnection_1 from the Component List drop-down list.
    2. Enter the name of the collection (TDI44990_2 in this scenario) to write the records in in the Collection field.
    3. Select Insert from the Action on data drop-down list.
    4. Click the Sync columns button to make sure the schema of this component has the same columns as those of the tLogRow_4 component.
      Check that the Mapping table has the same columns as that of the tLogRow_4 component.
    5. Leave other options as they are.
    This component inserts the record retrieved by the tMongoDBInput_2 component to the collection named TDI44990_2. Because the schema of this component has only one column named doc and the DB Column and Type of the column are * and String, this component writes the record to the collection as a string using a dynamic schema.
  7. Double-click tMongoDBInput_3 to open its Basic settings view and do the following.
    1. Select Use existing connection and select tMongoDBConnection_1 from the Component List drop-down list.
    2. Enter the name of the collection (TDI44990_1 in this scenario) to retrieve the records from in the Collection field.
    3. Click [...] next to Edit schema to open the schema editor and add a column with the column name of doc, DB Column of *, and Type of Object.
    4. Enter "{name:/^name2/}" in the Query field.
    5. Leave other options as they are.
    This component retrieves the record with the name field being name2 as an object from the TDI44990_1 collection.
  8. Double-click tMongoDBOutput_3 to open its Basic settings view and do the following.
    1. Select Use existing connection and select tMongoDBConnection_1 from the Component List drop-down list.
    2. Enter the name of the collection (TDI44990_2 in this scenario) to write the records in in the Collection field.
    3. Select Insert from the Action on data drop-down list.
    4. Click the Sync columns button to make sure the schema of this component has the same column as that of the tLogRow_5 component.
      Check that the Mapping table has the same columns as that of the tLogRow_5 component.
    5. Leave other options as they are.

    This component inserts the record retrieved by the tMongoDBInput_3 component to the collection named TDI44990_2. Because the schema of this component has only one column named doc and the DB Column and Type of the column are * and Object, this component writes the record to the collection as an object using a dynamic schema.

  9. Double-click tMongoDBInput_4 to open its Basic settings view and do the following.
    1. Select Use existing connection and select tMongoDBConnection_1 from the Component List drop-down list.
    2. Enter the name of the collection (TDI44990_2 in this scenario) to retrieve the records from in the Collection field.
    3. Click [...] next to Edit schema and add these columns to the schema: _id, type String; name, type String; address, type String, age, type Integer, and birth, type Date and date pattern "yyyy-MM-dd".
    4. Enter "{}" in the Query field.
      A string of "{}" queries all the records in the collection.
    5. Leave other options as they are.
    This component verifies the data written by tMongoDBOutput_2 and tMongoDBOutput_3 by retrieving and outputting all the records in the collection named TDI44990_2.