You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Per Ejeklint <ej...@mac.com> on 2010/02/18 17:43:29 UTC

View woes - no keys after reduce

I'm a bit confused. Running CouchDBX latest, trunk 910791. With this map/reduce functions

function(doc)
{
	if (doc.docType == "PersonAndOrganizationDoc")
	{
		emit(doc.organizations.organization[0].name, doc.persons.person.length);
	}
}

function(keys, values)
{
    return sum(values);
}

I get this from http://localhost:5984/paodb/_design/view1/_view/byName?reduce=false:

{"total_rows":6,"offset":0,"rows":[
{"id":"4fa43f2ba6fa2fb9e7b1dd1fcb680796","key":"JanLs AB","value":3},
{"id":"4fa43f2ba6fa2fb9e7b1dd1fcb67e4dd","key":"Lottas AB","value":3},
{"id":"4fa43f2ba6fa2fb9e7b1dd1fcb67e62d","key":"Lottas AB","value":3},
{"id":"4fa43f2ba6fa2fb9e7b1dd1fcb67f207","key":"Lottas AB","value":3},
{"id":"4fa43f2ba6fa2fb9e7b1dd1fcb67fb0b","key":"Nisses AB","value":3},
{"id":"4fa43f2ba6fa2fb9e7b1dd1fcb67ff49","key":"Nisses AB","value":3}
]}

Which looks ok to me. Then with reduce=true I get

{"rows":[
{"key":null,"value":18}
]}

The sum is ok, but I can't figure out what happened with my keys. Tell me I'm stupid - what have I missed?

/Per


Re: View woes - no keys after reduce

Posted by Per Ejeklint <ej...@mac.com>.
18 feb 2010 kl. 17.53 skrev Daniel Truemper:

> 
>> Which looks ok to me. Then with reduce=true I get
>> 
>> {"rows":[
>> {"key":null,"value":18}
>> ]}
> This is the output of the upmost reduce. Add "group=true" and you will have the keys again...
> 
> Daniel

Duh... how could I miss that. Been staring in the wrong direction and not noticing my bad URL. Thanks Daniel!


Re: View woes - no keys after reduce

Posted by Daniel Truemper <tr...@googlemail.com>.
> Which looks ok to me. Then with reduce=true I get
> 
> {"rows":[
> {"key":null,"value":18}
> ]}
This is the output of the upmost reduce. Add "group=true" and you will have the keys again...

Daniel