MongoDB + JSON Part Two

Continued from Part 1

Part 2: MongoDB → JSON

Step 1:  Create a new job

Create a separate job from Part 1.

We will begin by placing a tMongoDBInput component and connecting it to a tLogRow component.

In this job, we are only going to pull one of the three JSON items we loaded into the database. In this case, the one containing make:Toyota.

To do this, we will need to make sure we connect to the right Database, we used “Demos” last time, as well as the correct Collection “Cars”. Then, we need to make sure our output schema is correct so click the “Edit schema” button and make sure there is a column for each field.

Then make sure the Query is set to “{make : ‘Toyota’}”

The mapping should be auto-populated.

Step 2: Check your output.

If you haven’t already, add a tLogRow component to view the output and make sure it is correct.

Run the job to view the output.

Step 3: Convert to JSON file

Lastly, place a FileOutputJSON component at the end of the run sequence.

Set your path and name of the data block and sync columns.

Step 4: Run final job and view output

  1. Amy Maestas Reply

    hi, question about extraction of data from a mongodb with several embedded arrays into vertica. what would be the best way to go about this?
    thanks,

    • admin Reply

      Hi Amy, Thanks for you question.

      Generally speaking I would recommend utilizing the tMongoDBInput component to read the document into Talend, then utilize the tExtractJsonFields component to extract the normalized array you need. In many cases you may need to use the tReplicate component and multiple tExtractJsonFields components if you need to extract to multiple different data sets in Vertica. For the write to Vertica you can utilize the tVerticaOutput component. Please make sure you are using the “Big Data” version of TOS or TIS so that you have access to these components. Please let us know if you have any further specific questions or issues?

  2. Chris Lundy Reply

    Admin,
    This was a great tutorial. Very easy to follow and I had the environment setup and running in a matter of minutes. Very nice.

  3. Garry Munro Reply

    Hi Is there any way to set the query value for mongo dynamically ?

Leave a Reply

*

captcha *