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 :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending 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 :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending 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 :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending 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 :-)

 


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending their time for your query. If your query is answered, please mark the topic as resolved :-)

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch