incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Davis" <paul.joseph.da...@gmail.com>
Subject Re: Note to self...
Date Mon, 20 Oct 2008 16:04:37 GMT
On Mon, Oct 20, 2008 at 11:57 AM, kowsik <kowsik@gmail.com> wrote:
> Ok, I thought I understood this, but a little confused now. What
> exactly is the effect of passing group=true to a query? I was thinking
> it's mainly there to invoke the reduce function, if provided, no?
>
> In general though, what's the difference between:
>
> group=true
>    - when just a map function is provided

Nothing

>    - when both map and reduce are provided
>

Values are reduced such that all exactly matching keys are separate

Ie,

emit(1, 1)
emit(1, 2)
emit(2, 1)

And a reduce that is merely return sum(values) would yield:

1, 3
2, 1

> group_level=1
>    - when just a map function is provided

Nothing

>    - when both map and reduce are provided
>

group_level=1 only works when the emitted keys are arrays, otherwise
it behaves as group=true IIRC

But, assuming array keys,

emit([1, 1], 1)
emit([1, 2], 2)
emit([2, 0], 0)

and again, using return sum(values) as the reduce yields:

[1], 3
[2], 0

> Thanks,
>
> K.
>
> On Mon, Oct 20, 2008 at 1:08 AM, Paul Carey <paul.p.carey@gmail.com> wrote:
>>>> On trunk you can pass ?reduce=false to your query which means you'll
>>>> simply get the result of the map. This may be what you want.
>>
>>> Neat. But, how is this different from omitting group=true in the query?
>>
>> Simply because if a view contains both a map and reduce function,
>> querying that view will by default return the result of the reduce
>> function, irrespective of whether group or group_level are absent.
>>
>> Paul
>>
>

Mime
View raw message