I use cbdocloader command to import different json file into couchbase database. If my file content json like below
{"displayName":"Login","controller":"AppCtrl","action":"login","endpoint":"","group":0,"_type":"Permission"}
it is working fine.
But if my json content _id it will automatically exclude it from import I want to import my json like below
{"_id":"3dfd4bb0-aff4-11e6-8a96-8598a3ef40c4","displayName":"Login","controller":"AppCtrl","action":"login","endpoint":"","group":0,"_type":"Permission"}
How can I do this using cbdocloader ??
Couchbase Server 4.5 treats _id
in a different way:
https://github.com/couchbase/couchbase-cli/blob/4.5.0/pump_json.py#L41-L62
Next version will use new docloader, which does not do it anymore. You can build it standalone: https://github.com/couchbase/docloader
export GOPATH=/tmp/gopath
mkdir -p $GOPATH
cd $GOPATH
go get github.com/couchbase/docloader/cmd/cbdocloader
It produces single static binary at
./bin/cbdocloader
Man page also located in the repository
man src/github.com/couchbase/docloader/man/man1/cbdocloader.1
You can see demo of this new docloader recorded on Connect 2016: https://www.youtube.com/watch?v=OlK9R5Fqmpo
I get the solution I have changed a condition " if '_id' not in doc: " in following file /opt/couchbase/lib/python/pump_json.py
来源:https://stackoverflow.com/questions/40740476/import-json-file-into-couchbase-using-cbdocloader