I need to learn couchbd and have been going through tutorials on views. I understand them conceptually, but in practice I am unable to effectively supply view parameters when I query a view. I am following the syntax in examples to the best of my ability. So I have the following simple design document:
{"_id":"_design/simple","_rev":"1-0391fe242d8b6045da1984283287f91c","views":{"foo":{"map":"function(doc) { if(doc.date && doc.title) {emit(doc.date, doc.title);}}"}}}
I can query the view foo without any view parameters and get the following result:
curl http://127.0.0.1:5984/viewtester/_design/simple/_view/foo
produces
{"total_rows":3,"offset":0,"rows":[
{"id":"hello-world","key":"2009/01/15 15:52:20","value":"Hello World"},
{"id":"biking","key":"2009/01/30 18:04:11","value":"Biking"},
{"id":"bought-a-cat","key":"2009/02/17 21:13:39","value":"Bought a Cat"}
]}
But adding a view parameter doesn’t seem to work:
curl http://127.0.0.1:5984/viewtester/_design/simple/_view/foo?key="2009/01/15 15:52:20"
produces no output, just sending me to the next command prompt. I’ve tried various examples with different types of keys and have run into the same issue.
Any insight into what I’m doing wrong would be greatly appreciated.
Thanks, Nowell
Cheeso is right, you have to URL encode your value, not just the
"s, but the other chars as well. In fact, replacecurlwithechoto see what your shell really passes to curl after it has finished processing.FWIW, I think most of us hit do our read queries, like hitting views, in a browser – so all the url-encoding is taken care of for us.