Details
-
Bug
-
Resolution: Won't Fix
-
None
-
None
-
*Location*: http://developer.couchbase.com/documentation/server/4.0/developer-guide/views-querying.html#
*User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7
*Screen Resolution*: 1440 x 900
Description
The documentation says that the selection (for instance function key) is applied after the reduce function. Why do I get the following results ?
If I have the documents :
{ "k1": 1, "k2": 1 } { "k1": 1, "k2": 2 }and the map is : emit([doc.k1, doc.k2], null)
and the reduce is: _count
why do I get the following results ?
query.group_level(1).key(1) = 0 // expected 2
query.group_level(1).key([1,1]) = 1 // expected 0
It seems that key is applied before the grouping/reduce function. If you execute query.group_level(1), you got a single result :
[1] => 2
If you add .key(xxx), the data set of the views seems to be filtered to match only the key xxx.
if xxx=1, there is no result because there is no row in the view with the key 1.
if xxx=[1,1] there is a single result because there is a single row with the key [1,1]
Is there something wrong in my tests ?