Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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.

Labels (4)
8 Replies
Anonymous
Not applicable
Author

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 🙂

Anonymous
Not applicable
Author

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.0683p000009M34U.png

Anonymous
Not applicable
Author

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 🙂

Anonymous
Not applicable
Author

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?

Anonymous
Not applicable
Author

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 🙂

Anonymous
Not applicable
Author

(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?

Anonymous
Not applicable
Author

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 🙂

 

ericlwc
Contributor
Contributor

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?