Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

endkey is ommited when querying with grouping #102

Open
sasnal opened this issue Mar 27, 2012 · 0 comments
Open

endkey is ommited when querying with grouping #102

sasnal opened this issue Mar 27, 2012 · 0 comments

Comments

@sasnal
Copy link

sasnal commented Mar 27, 2012

Hi,
We have following problem with BigCouch in our project.

View is created in database "mydb" in design document "_design/designdoc2" ("_id" and "_rev" fields were removed for better readability):

{
   "language": "javascript",
   "views": {
       "removeDuplicatesView": {
           "map": "function(doc) {emit([doc.myPropertyKey, doc.myId], doc);}",
           "reduce": "function(key, values) {return values[0];}"
       }
   }
}

And documents exists in database ("_id" and "_rev" fields were removed for better readability):

{"myId": "any1",  "myPropertyKey": "value1"}
{"myId": "any2",  "myPropertyKey": "value2"}
{"myId": "any3",  "myPropertyKey": "value3"}
{"myId": "any4",  "myPropertyKey": "value3"}
{"myId": "any5",  "myPropertyKey": "value5"}
{"myId": "any6",  "myPropertyKey": "value6"}
{"myId": "any7",  "myPropertyKey": "value7"}

When querying http://myhost:5984/mydb/_design/designdoc2/_view/removeDuplicatesView?group_level=1
I receive correct response:

{"rows":[
{"key":["value1"],"value":{"_id":"b7a19351208b8421a406aaa68e94d069","_rev":"2-b5901bd64ab86d96fb53b657d36be5c7","myId":"any1","myPropertyKey":"value1"}},
{"key":["value2"],"value":{"_id":"b7a19351208b8421a406aaa68e94d9e2","_rev":"2-bda8e0d4b60fd33094db9b7ecc76b304","myId":"any2","myPropertyKey":"value2"}},
{"key":["value3"],"value":{"_id":"b7a19351208b8421a406aaa68e94d9ee","_rev":"3-834901a91c9b1e45cbd55201838a486b","myId":"any3","myPropertyKey":"value3"}},
{"key":["value5"],"value":{"_id":"b7a19351208b8421a406aaa68e94e1d2","_rev":"2-8fdc99b2f92529b46b57cc28bbe4f8d0","myId":"any5","myPropertyKey":"value5"}},
{"key":["value6"],"value":{"_id":"b7a19351208b8421a406aaa68e94e1d8","_rev":"2-a1c7462b90bc8083ca22ab51b034c8df","myId":"any6","myPropertyKey":"value6"}},
{"key":["value7"],"value":{"_id":"b7a19351208b8421a406aaa68e94e226","_rev":"3-bfe9c3a77a3d4988d72033d73e93141b","myId":"any7","myPropertyKey":"value7"}}
]}

But when querying http://myhost:5984/mydb/_design/designdoc2/_view/removeDuplicatesView?group_level=1&startkey=%5B%22value2%22%5D&endkey=%5B%22value6%22%5D
Document with key, which is endkey (["value6"] in that case) is missing:

{"rows":[
{"key":["value2"],"value":{"_id":"b7a19351208b8421a406aaa68e94d9e2","_rev":"2-bda8e0d4b60fd33094db9b7ecc76b304","myId":"any2","myPropertyKey":"value2"}},
{"key":["value3"],"value":{"_id":"b7a19351208b8421a406aaa68e94d9ee","_rev":"3-834901a91c9b1e45cbd55201838a486b","myId":"any3","myPropertyKey":"value3"}},
{"key":["value5"],"value":{"_id":"b7a19351208b8421a406aaa68e94e1d2","_rev":"2-8fdc99b2f92529b46b57cc28bbe4f8d0","myId":"any5","myPropertyKey":"value5"}}
]}

Document with key "myId" and value "any3" is sometimes replaced by document with value "any4", but that's expected because of current implementation of reduce function.

When adding parameter "descending=true" to query and swapping startkey and endkey, behavior is analogous, but instead of endkey, startkey is ommited in response.

Version of BigCouch is 0.4.0-1.el6.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant