How to add list of json object in couchbase server bucket

Four Stars

How to add list of json object in couchbase server bucket

As per the requirement I have to write some custom code in routines of Talend job and I can call it using any java component. Now I have the list of JSON object which I need to save on couchbase server bucket. I have tried it by using tcouchbaseoutput.  But I cant understand how to map the schema of tcouchbaseoutput to the custom json list. Please give me solution.

Employee

Re: How to add list of json object in couchbase server bucket

Hi,

 

   Could you please add some screen shots of the job flow and components so that we will get better idea of your use case?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Four Stars

Re: How to add list of json object in couchbase server bucket

I have list of jsonobject and I want to add it as document in bucket.Here I am attaching screenshot of job which has sample code please help me to solve this.Untitled.png

Employee

Re: How to add list of json object in couchbase server bucket

Hi,

 

    First you will have to convert your data to JSON using tWriteJSONField.

 

https://help.talend.com/reader/KxVIhxtXBBFymmkkWJ~O4Q/50PMKM8mz4A5fAL~FQcLHw

 

Then you can cast the output String containing JSON to Document using tConvertType component. Once its done, you can try to insert the data to target area as Document datatype.

 

   Since I do not have CouchDB handy, I am not able to test it myself.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Four Stars

Re: How to add list of json object in couchbase server bucket

Hi,

Actually the problem is that the JSON fields are dynamic. It will be different every time so I cant map it in tWriteJSONField. I need to execute dynamic multiple queries and for running the dynamic query the enterprise edition required. For overcome this I find solution to execute the query using java code in routine. Now I need to store this result on couchbase server for this I am creating json list of that resultset. How can I save it on couchbase server?

Employee

Re: How to add list of json object in couchbase server bucket

Hi,

 

    You can call your custom routine from a tjavarow component (assuming each input row will give separate JSON data) which will generate the output JSON resultset. This result set will be in String format if you have set the return type accordingly.

 

    Now, you can convert this output String to target datatype using tConvertType component. The output data type in the schema could be in Document or Object based on your need. THis can be inserted to tCouchbaseOutput after verifying the target data type.

 

    I would like to test this flow but I do not have a Couchbase database handy with me. Could you please try it and let us know whether it helped in your case?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Four Stars

Re: How to add list of json object in couchbase server bucket

(assuming each input row will give separate JSON data) which will generate the output JSON resultset" I have lots of rows in resultset.

 

Is it okay if I write the java code to add the data in couchbase server in routine?

Employee

Re: How to add list of json object in couchbase server bucket

Hi,

 

    You can add the custom code inside a tjavarow, tMap or a custom routine. The advantage of custom routine is that it can be reused within multiple Talend jobs once you attach the routine to the Talend Job.

 

    You can refer how the routines are embedded into a Talend job with following real time example.

 

https://community.talend.com/t5/Design-and-Development/Talend-and-Amazon-Comprehend-Integration/ta-p...

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 

One Star

Re: How to add list of json object in couchbase server bucket

Hi ,

 

i have tried what the twritejsonfield > tconverttype > tcouchbaseoutput on 2 type of data types:
1) object - im getting weird result when loaded into the couchbase bucket. the json structure became a string

"Children":"[{\"Name\":\"Alice\",\"Age\":7},{\"Name\":\"Bob\",\"Age\":5},{\"Name\":\"Carole\",\"Age\":1}]

2) document  im getting error "document Nested exception: Content is not allowed in prolog."

 

also the Tcouchbaseoutput component requires a "ID". do i need to define this ID?

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Put Massive Amounts of Data to Work

Learn how to make your data more available, reduce costs and cut your build time

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now