Find One on view=> curl: (52) Empty reply from server #2932
-
DescriptionI followed the instructions in the documentation for Find One on a view, but that don't work for me. Current BehaviorI followed every step to create a view with the function map:
And i have aggregate the three example documents. When i query the view with
But when I try to find a single document with I use
Also i try with
Expected BehaviourI should get the “Biking” blog post:
Your Environment
Additional Context |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is probably escaping biting you. Here's the full example on 3.1.0 driven from Linux. In this example, my CouchDB is at $ curl -X PUT http://localhost:15984/abc
{"ok":true}
$ curl -X POST -H "Content-Type:application/json" http://localhost:15984/abc -d '{"_id":"biking","title":"Biking","body":"My biggest hobby is mountainbiking. The other day...","date":"2009/01/30 18:04:11"}'
{"ok":true,"id":"biking","rev":"1-9e21110dc665c8e0201643aa3ad3aeaf"}
$ curl -X POST -H "Content-Type:application/json" http://localhost:15984/abc -d '{"_id":"bought-a-cat","title":"Bought a Cat","body":"I went to the the pet store earlier and brought home a little kitty...","date":"2009/02/17 21:13:39"}'
{"ok":true,"id":"bought-a-cat","rev":"1-ccd0a7e95ade7eb2d29cc02ffa582b30"}
$ curl -X POST -H "Content-Type:application/json" http://localhost:15984/abc -d '{"_id":"hello-world","title":"Hello World","body":"Well hello and welcome to my new blog...","date":"2009/01/15 15:52:20"}'
{"ok":true,"id":"hello-world","rev":"1-97dd85b06c25328a300f3f4041def370"}
$ curl http://localhost:15984/abc/_all_docs
{"total_rows":3,"offset":0,"rows":[
{"id":"biking","key":"biking","value":{"rev":"1-9e21110dc665c8e0201643aa3ad3aeaf"}},
{"id":"bought-a-cat","key":"bought-a-cat","value":{"rev":"1-ccd0a7e95ade7eb2d29cc02ffa582b30"}},
{"id":"hello-world","key":"hello-world","value":{"rev":"1-97dd85b06c25328a300f3f4041def370"}}
]}
$ curl -X PUT -H "Content-Type:application/json" http://localhost:15984/abc/_design/docs -d '{"language":"javascript","views": {"by_date":{"map":"function(doc) {if(doc.date && doc.title) { emit(doc.date, doc.title) } };"}}}'
{"ok":true,"id":"_design/docs","rev":"1-e961555ed4f1dc188a6610d092b68393"}
$ curl http://localhost:15984/abc/_design/docs/_view/by_date
{"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"}
]}
$ curl 'http://localhost:15984/abc/_design/docs/_view/by_date?key="2009/01/30%2018:04:11"'
{"total_rows":3,"offset":1,"rows":[
{"id":"biking","key":"2009/01/30 18:04:11","value":"Biking"}
]} Note the use of If you're running curl on Windows, you need to go through some extra machinations to get curl to correctly escape the content. You can't use single-quotes, only double quotes, which means the internal double-quotes around the key have to be escaped like this:
Hope this works for you - if so, please mark my answer as correct! 😉 |
Beta Was this translation helpful? Give feedback.
This is probably escaping biting you.
Here's the full example on 3.1.0 driven from Linux. In this example, my CouchDB is at
http://localhost:5984/
.