CouchDB视图URL显示:CouchDB:{“error”:“not_found”,“reason”:“missing”} ...为什么?

时间:2011-05-23 14:55:30

标签: view couchdb

例如:

  • 我的CouchDB托管于:example.com
  • CouchDB数据库名称为:foo
  • 视图名称为:my_view

所以,当我把这些放在一起构建URL时,我得到:

以上网址显示:

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

为什么会出现此错误?

预期结果是列出了与“my_view”视图对应的文档。

更多信息:

如果我访问http://www.example.com/foo,我会收到预期的回复:

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

如果我访问http://www.example.com/foo/_design/my_view,我会收到预期的回复:

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

我在Windows7 / Chrome上使用CouchDB v1.0.2

我的设计文档的完整内容(显示实际值,而不是example.com)

{
  "_id":"_design/locations",
  "_rev":"1-0f7fbdd2f5b4213591e171b6e546af3a",
  "language":"javascript",
  "views": {
    "locations": {
      "map":"function(doc) {\n  emit(doc.type === \"location\" && doc.name);\n}"
    }
  }
}

1 个答案:

答案 0 :(得分:10)

正确的网址路径为/<db>/_design/<design>/_view/<view>

根据评论中提供的真实网址,这将是正确的网址:

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

确实它会返回预期的视图:

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

仅查询/ _design / locations将返回文档本身:

{"_id":"_design/locations","_rev":"1-0f7fbdd2f5b4213591e171b6e546af3a","language":"javascript","views":{"locations":{"map":"function(doc) {\n  emit(doc.type === \"location\" && doc.name);\n}"}}}