View Query with Keys Not Fully Reduced


#1

Accessing a view through the Ruby client, but this issue does show up through the console. The query is against a two node deployment using 2.2.0 enterprise, build 821.

When I query requesting grouping and no keys parameter, I receive a fully reduced set of results. For example, a query may look like this:

http://192.68.50.101:8092/sw1/_design/assignments/_view/type_grouping?group=true

I’ll receive results that look like the following:

{"rows":[ ... {"key":["a3dbe271-03c1-4cb7-a638-b2a3cb80cf47","resident-issue"],"value":5}, ... ] }

This is a full result set with different keys, etc., one of which is a fully reduced count of resident-issue for that specific guid.

When I modify the query to include a “keys” parameter and to restrict the result to select issue types (including resident-issues) for that guid, I don’t seem to be getting fully reduced results anymore. The query changes to:

http://192.68.50.101:8092/sw1/_design/assignments/_view/type_grouping?group=true&keys=%5B%5B%22a3dbe271-03c1-4cb7-a638-b2a3cb80cf47%22%2C%22work-order%22%5D%2C%5B%22a3dbe271-03c1-4cb7-a638-b2a3cb80cf47%22%2C%22resident-issue%22%5D%5D

The result changes to:

{"rows":[ {"key":["a3dbe271-03c1-4cb7-a638-b2a3cb80cf47","resident-issue"],"value":4}, {"key":["a3dbe271-03c1-4cb7-a638-b2a3cb80cf47","work-order"],"value":2}, {"key":["a3dbe271-03c1-4cb7-a638-b2a3cb80cf47","resident-issue"],"value":1} ] }

So nothing is different between the two queries except the addition of a “keys” parameter restricting the result set to just two of the keys that were in the original result set.

When I do not include the keys param I get fully reduced results for the resident-issues on that guid. When I include the keys param with more than just the resident-issue type (i.e. the work-order one) then I start getting results that are not reduced. I’m using the builtin _count reduction function.

Since the key-less query always fully reduces my resident-issue row, and since the keys really look like they match, it seems to me that there is a failure to reduce or re-reduce at some level when passing in keys.

My question: What am I missing? Is my expectation that I would get fully reduced results in this case off-base? Should I generally code to assume that I need to do a kind of manual final reduction?

Any help to clarify my thinking would be appreciated!