I have a data file that I would like to import into Couchbase. It has Nested JSON (subdocuments). Here is the first line of many similar lines, notice the custom_params which is nested JSON which may have multiple elements not just Level:
The cbimport tool allows importing of JSON data. If you need something a little more custom that that, you might take a look at a utility I personally wrote:
It is essentially a Golang script that will read a file line by line and import it into Couchbase. The script I wrote was intended for importing MongoDB data so it does some custom stuff, but you can see how you might incorporate your own custom stuff through it.
Can you please tell me how can I use the “metaid” filed in “–generate-key” field. So that, same meta().id can be imported in new environment. Actually I have a requirement to export and import the same data including meta().id from production bucket to stage bucket.
Thanks for your help.
I have run cbimport command using this "–generate-key %metaid% " and it works.
But, I don’t want this field within the document value . So , is there is any way to omit this attribute loading under document value.
Yes, use the syntax I’ve described. Unless key and generate-key are the same operations. Please show an example of your import data, and what you are expecting.
Now import this data like below : ID Value Profit:1 {“indent”:0,“lineItemID”:1,“smeFinalLanguage”:“General Statement”} Profit:2 {“indent”:1,“lineItemID”:2,“smeFinalLanguage”:"Financial statements "}
While importing the data using your syntax, it is showing like below: ID Value Profit:1 {“indent”:0,“lineItemID”:1,“smeFinalLanguage”:“General Statement”,“metaid”:“Profit:1”} Profit:2 {“indent”:1,“lineItemID”:2,“smeFinalLanguage”:"Financial statements ",“metaid”:“Profit:2”}
Just use the syntax I posted previously. I didn’t use generate-key, just key. As stated, if my syntax also doesn’t work, you could just delete the field after the import.