Hi,

2016-09-01 12:22 GMT+02:00 Giridhar Addepalli <[email protected]>:

> Hi,
>
> Function declaration for reduce functions look like
>
> function(keys, values, rereduce) {
> }
>
> My doubt is regarding the 'keys' parameter.
> Can multiple keys be passed to single invocation of custom reduce function
> ?
>

Yes. Each key corresponds to the value of the same index.
The keys could be same but could also differ if the view was queried with a
grouplevel.

e.g. you have 3 documents, the view emits the keys:
[1,2,3]
[1,2,4]
[1,3,5]

if you call the view with "group_level" = 1, reduce will be called once¹
and keys² will be:
[
[[1,2,3], documentid],
[[1,2,4], documentid],
[[1,3,5], documentid]
]

the result is assigned to "[1]"

if you call the view with "group_level" = 2, reduce will be called twice¹
and keys² will be:
[
[[1,2,3], documentid],
[[1,2,4], documentid]
]

this result is assigned to "[1,2]"

and
[
[[1,3,5], documentid]
]

this result is assigned to "[1,3]"


Hope this helps,
Stefan


[1]: ignoring rereduce
[2]: CouchDB 1.6.1 here

Reply via email to