One Star

MongoDb Output - How to Write Array fields/values in a collection?

Hello,
I have a need to write string arrays into a mongodb collection and I am using Talend Big Data and the components that come with that.
However, I do not see any option to define the output field as an array. Is writing to array possible?
Example:
This is the key/value format I need in my collection.
search_key:
4 REPLIES
Moderator

Re: MongoDb Output - How to Write Array fields/values in a collection?

Hi,
I think you need a tjavaflex component in your job design.
See the related forum Forum 28545
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: MongoDb Output - How to Write Array fields/values in a collection?

Thank you. This is good insight. However, I am getting the value of NULL now.
Here is what I am doing:
tMongodbConnection -->
SQLInput --> tjavaflex --> tmap --> tMongoOutput
tjavaflex:
Start:
// start part of your Java code
java.util.ArrayList list1 = new java.util.ArrayList();

Main:
list1.add("hello");
list1.add("there");
list1.add("test");
globalMap.put("latlong", list1);
-------------------
Then in tmap, I on right side, I have:
column: latlongtest, type: list, Expression: (java.util.ArrayList)globalMap.get("latlong")

I also tried entering (java.util.ArrayList)globalMap.get("latlong") in the Variable section but still getting NULL in mongodb.
latlongtest is defined as list in mongodb schema.
Please help as my project is due on Monday.
Thanks.
Moderator

Re: MongoDb Output - How to Write Array fields/values in a collection?

Hi,
To make a testing for that, you can use a tlogrow instead of tMongoOutput in your work flow to see if there any data can be out put on console?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: MongoDb Output - How to Write Array fields/values in a collection?

I did try tLogRow and it shows null.
Is there any documentation of Array/List and globalMap.put?