couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <robert.new...@gmail.com>
Subject Re: Map/Reduce Question
Date Fri, 03 Dec 2010 09:42:12 GMT
add group_level=1 to get the unique foo's.

On Fri, Dec 3, 2010 at 9:41 AM, Robert Newson <robert.newson@gmail.com> wrote:
> Matthew,
>
> Your original message implied that you might have duplicates but I
> didn't notice that you had documents with the same key but different
> contents (and there isn't one in your example).
>
> You can't reduce your way out of that, I think. What you can do instead is;
>
> map:
>
> function(doc) {
>  if (doc.foo != '' && (doc.bar != '' || doc.baz != '')) {
>    emit([doc.foo, doc.bar, doc.baz], null);
>  }
> }
>
> reduce:
>
> function(keys, values, rereduce) {
>  return null;
> }
>
> When queried with group=true, you'll get one row for every unique
> combination of foo, bar and baz.
>
> B.
>
>
>
>
> On Thu, Dec 2, 2010 at 11:57 PM, Matthew Woodward <matt@mattwoodward.com> wrote:
>> On Thu, Dec 2, 2010 at 3:50 PM, Randall Leeds <randall.leeds@gmail.com>wrote:
>>
>>> I think you may want to play w the ?group_level query parameter.
>>>
>>
>> Thanks--messed with that but since my keys weren't unique across records it
>> didn't seem to make a difference. I'll look back into that though.
>>
>> --
>> Matthew Woodward
>> matt@mattwoodward.com
>> http://blog.mattwoodward.com
>> identi.ca / Twitter: @mpwoodward
>>
>> Please do not send me proprietary file formats such as Word, PowerPoint,
>> etc. as attachments.
>> http://www.gnu.org/philosophy/no-word-attachments.html
>>
>

Mime
View raw message