Reputation: 1
My task is to upadate some document on couchbase from a file json. I have these document on couchbase:
Document 1
{ "id":"1", "car":"bmw", "colore":"white"}
Document 2
{ "id":"2", "car":"mini", "model":"cooper","colore":"black"}
Document 3
{ "id":"3", "car":"ferrari", "model":"california", "colore":"red"}
Document 4
{ "id":"4", "car":"porsche", "model":"cayenne", "colore":"blue"}
I receive in a specific folder a File json containing some json to update these documents with the same id:
{ "id":"1", "model":"serie1"}
{ "id":"2", "displacement":"1600"}
{ "id":"3", "model":"testarossa"}
{ "id":"4", "style":"suv"}
I must import data from these file json.
I try to use command cbimport:
bin\cbimport json -c [host]:8091 -u username -p password -b Default -d file://data/file.json -f lines -g %_id%
The result of cbimport is:
Document 1
{ "id":"1", "model":"serie1"}
Document 2
{ "id":"2", "displacement":"1600"}
Document 3
{ "id":"3", "model":"testarossa"}
Document 4
{ "id":"4", "style":"suv"}
The RESULT I want is:
Document 1
{ "id":"1", "car":"bmw", "colore":"white","model":"serie1"}
Document 2
{ "id":"2", "car":"mini","model":"cooper","colore":"black","displacement": "1600"}
Document 3
{ "id":"3", "car":"ferrari", "model":"testarossa", "colore":"red"}
Document 4
{ "id":"4", "car":"porsche", "model":"cayenne", "colore":"blue", "style":"suv"}
Upvotes: 0
Views: 78
Reputation: 2460
Assuming that cbimport is on your path, just run something like:
cbimport json -c couchbase://127.0.0.1 -u your_username -p your_password -b your_bucket_name -d file:///Users/deniswsrosa/Desktop/files.json -f lines -g %id% -t 4
Upvotes: 1