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

发布于 2024-11-09 08:52:50 字数 1185 浏览 0 评论 0原文

例如:

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

因此,当我将这些放在一起构建 URL 时,我得到:

上面的 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":"...

我正在使用 CouchDB v1.0.2,适用于 Windows7/Chrome

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

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

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:

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}"
    }
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那小子欠揍 2024-11-16 08:52:50

正确的 URL 路径是 //_design//_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}"}}}

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}"}}}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文