couchbase startkey_docid 和复杂密钥

Mic*_*ael 6 couchdb couchbase

下面使用匹配结果集的调用返回的结果不以文档 ID a4a6cf44-8a82-494a-a2b9-f6a3ec629f17 开头。正如下面的结果集所示,前 3 个键是相同的,但 startkey_docid 没有效果。

围绕这个只有几个问题

  • startkey_docid 使用复杂密钥可以正常工作吗?(这显然适用于 couchdb)
  • 如果上述答案是肯定的,那么在我们看来,问题的根源是 dateToArray(doc.created) 的使用吗?
  • 这是一个错误吗?

看法:

function (doc, meta) 
{
  if(meta.type == "json" && doc.type == "POST") 
  {
    emit([doc.category, dateToArray(doc.created), doc.visibility], null);
  }
}
Run Code Online (Sandbox Code Playgroud)

称呼:

?startkey=["auto",[2013,10,10,23,12,0],"EVERYONE"]&endkey=["auto",[2013,12,11,23,12,0],"EVERYONE"]&startkey_docid=a4a6cf44-8a82-494a-a2b9-f6a3ec629f17
Run Code Online (Sandbox Code Playgroud)

结果:

{
    total_rows: 20,
    rows: [{
        id: "a4a6cf44-8a82",
        key: ["auto", [2013, 11, 8, 1, 17, 46], "EVERYONE"],
        value: null
    }, {
        id: "a4a6cf44-8a82-494a-a2b9",
        key: ["auto", [2013, 11, 8, 1, 17, 46], "EVERYONE"],
        value: null
    }, {
        id: "a4a6cf44-8a82-494a-a2b9-f6a3ec629f17",
        key: ["auto", [2013, 11, 8, 1, 17, 46], "EVERYONE"],
        value: null
    }, {
        id: "41070cfc-a85c-424c-9b87-fce0616c77c1",
        key: ["auto", [
        2013, 11, 11, 20, 28, 21], "EVERYONE"],
        value: null
    }, {
        id: "bb275e3c-54da-4e85-8cc3-21defff4e278",
        key: ["auto", [
        2013, 11, 13, 1, 41, 7], "EVERYONE"],
        value: null
    }]
}
Run Code Online (Sandbox Code Playgroud)

示例数据集。post_id 是文档 ID。

{
    type: "POST",
    post_id: "a4a6cf44-8a82",
    visibility: "EVERYONE",
    userID: "<user_id>",
    title: "Some title 1",
    category: "auto",
    description: "",
    created: "2013-11-07 17:17:46 -0800",
    modified: "2013-11-07 17:17:46 -0800"
}, {
    type: "POST",
    post_id: "a4a6cf44-8a82-494a-a2b9",
    visibility: "EVERYONE",
    userID: "<user_id>",
    title: "Some title 2",
    category: "auto",
    description: "",
    created: "2013-11-07 17:17:46 -0800",
    modified: "2013-11-07 17:17:46 -0800"
}, {
    type: "POST",
    post_id: "a4a6cf44-8a82-494a-a2b9-f6a3ec629f17",
    visibility: "EVERYONE",
    userID: "<user_id>",
    title: "Some title 3",
    category: "auto",
    description: "",
    created: "2013-11-07 17:17:46 -0800",
    modified: "2013-11-07 17:17:46 -0800"
}, {
    type: "POST",
    post_id: "41070cfc-a85c-424c-9b87-fce0616c77c1",
    visibility: "EVERYONE",
    userID: "<user_id>",
    title: "Some title 4",
    category: "auto",
    description: "",
    created: "2013-11-11 12:28:21 -0800",
    modified: "2013-11-11 12:28:21 -0800"
}, {
    type: "POST",
    post_id: "bb275e3c-54da-4e85-8cc3-21defff4e278",
    visibility: "EVERYONE",
    userID: "<user_id>",
    title: "Some title 5",
    category: "auto",
    description: "",
    created: "2013-11-12 17:41:07 -0800",
    modified: "2013-11-12 17:41:07 -0800"
}
Run Code Online (Sandbox Code Playgroud)

小智 0

您可以在这里找到有关如何startkey_docid正确使用的更多信息: http: //blog.couchbase.com/startkeydocid-behaviour