Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB view URL shows: CouchDB: {"error":"not_found","reason":"missing"} ... Why?

Tags:

view

couchdb

For example:

  • My CouchDB is hosted on: example.com
  • The CouchDB database name is: foo
  • The View name is: my_view

So, when I put these together to construct the URL, I get:

  • http://www.example.com/foo/my_view

The above URL shows:

 {"error":"not_found","reason":"missing"}

Why is this error given?

The expected result is that that the documents corresponding to the "my_view" view are listed.

More Info:

If I visit http://www.example.com/foo, I get the expected response:

{"db_name":"foo","...

If I visit http://www.example.com/foo/_design/my_view, I get the expected response:

{"_id":"_design/my_view","_rev":"...

I'm using CouchDB v1.0.2 on Windows7/Chrome

Full content of my design document (real values shown, not example.com)

{
  "_id":"_design/locations",
  "_rev":"1-0f7fbdd2f5b4213591e171b6e546af3a",
  "language":"javascript",
  "views": {
    "locations": {
      "map":"function(doc) {\n  emit(doc.type === \"location\" && doc.name);\n}"
    }
  }
}
like image 202
edt Avatar asked May 23 '11 14:05

edt


1 Answers

The correct URL path is /<db>/_design/<design>/_view/<view>.

From your real URL given in the comments, this would be the correct URL:

http://burritohunter.com/couchdb/burritohunter/_design/locations/_view/locations

And indeed it returns the expected view:

{"total_rows":2,"offset":0,"rows":[
{"id":"86bb31389b78aa5921f7a2f5c0000915","key":"Billy's","value":null},
{"id":"jimmys","key":"Jimmy's","value":null}
]}

Querying only /_design/locations will return the document itself:

{"_id":"_design/locations","_rev":"1-0f7fbdd2f5b4213591e171b6e546af3a","language":"javascript","views":{"locations":{"map":"function(doc) {\n  emit(doc.type === \"location\" && doc.name);\n}"}}}
like image 194
Matt Goodall Avatar answered Nov 03 '22 23:11

Matt Goodall