Hi guys, through Google, I found an article in this forum about “How to bulk import design docs and views to couchbase server”, but in practice, I still run into problems for importing views successfully. Here is the details.
// in my shell script file, I have …
cbdocloader -n 127.0.0.1:8091 -u $ADMIN_LOGIN -p $ADMIN_PASSWORD -b audit_bucket_name /staticDocs/auditData
// Under the ‘desidn_docs’ sub-folder, I have a json file whose content is simplified as follows
{
“id”: “design/dev_views”,
“language”: “javascript”,
“views”: {
“GetDocuments” : {
“map”: “function (doc, meta) { emit(meta.id, null); }”
}
}
After I run the shell script, from couchbase web console, I can see that the static document is imported to couchbase server successfully (under the ‘audit_bucket_name’ bucket, but I did not see the view in the ‘security_bucket_name’ bucket.
I am not clear where it went wrong. Is that command not specified correctly? or the json design document is not defined correctly? Please point it to me where it went wrong, your help is really appreciated.
Would you mind attaching an example zip file, so I could try it? I’m not able to reproduce the issue on my own. Also, what version of Couchbase Server are you using?
I noticed that if I run the above command, it will only load the json file/data into the data_bucket as a document, not as a view.
And if I try to use port 8092 in the above command, I got the following error messages
Traceback (most recent call last):
File “/opt/couchbase/lib/python/cbdocloader”, line 190, in
pump_transfer.exit_handler(DocLoader().main(sys.argv))
File “/opt/couchbase/lib/python/cbdocloader”, line 178, in main
self.init_bucket()
File “/opt/couchbase/lib/python/cbdocloader”, line 91, in init_bucket
self.rest = RestConnection(server_info)
File “/opt/couchbase/lib/python/couchbase/rest_client.py”, line 187, in init
self.couch_api_base = config[“nodes”][0].get(“couchApiBase”)
KeyError: ‘nodes’
I noticed that it uploads JSON from a .zip file. For that reason, in my latest test, I zipped my json file to a zip file and replaced the json file with the zip file in my ‘design_docs’ folder. This time, running the cbdocloader didn’t even load the zip file.