couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <N.Breun...@vpro.nl>
Subject RE: Writing View to Get Unique Values in Arrays Across Documents
Date Thu, 20 Jan 2011 07:32:00 GMT
I suggest checking the log file to get the actual error message or using an HTTP tool which
will show you the error message properly (curl for instance), but my guess is that you're
hitting the reduce limit. A reduce function is supposed to actually reduce the map result,
and CouchDB has a heuristic that detects if it doesn't do this and warns you. There is a reduce_limit
setting to disable this check, but I recommend to write reduce functions that actually reduce
the amount of data. Not reducing (enough) kills performance because of the intermediate storage
of the reduce result.

Nils.
________________________________________
Van: Matthew Woodward [matt@mattwoodward.com]
Verzonden: donderdag 20 januari 2011 7:21
Aan: user@couchdb.apache.org
Onderwerp: Re: Writing View to Get Unique Values in Arrays Across Documents

On Wed, Jan 19, 2011 at 3:48 PM, Jan Lehnardt <jan@apache.org> wrote:

>
> http://guide.couchdb.org/editions/1/en/cookbook.html#unique


I'm sure I'm doing something wrong but for the life of me I can't get that
example to work. It seems to choke when I try to emit each item in the array
as a variable name in the forEach loop.

For example, this works but isn't what I want to output. Just tried this to
see if the forEach was working which based on the document count I get back
it seems to be.

{
   "byOffice": {
       "map": "function(doc) { if (doc.office != '' && doc.witnesses !=
'[]') { doc.witnesses.forEach(function(witness) { emit(doc.office, null);});
}}"
   }
}

So that outputs doc.office for each witness which isn't what I want, but as
I said based on the guesstimate of the rows returned compared to what I know
about the data that seems to be more or less accurate. So the loop is
working at least.

When I change to this, however, things fail:
{
   "byOffice": {
       "map": "function(doc) { if (doc.office != '' && doc.witnesses !=
'[]') { doc.witnesses.forEach(function(witness) { emit(witness, null);});
}}"
   }
}

In Firefox I get a blank white screen and view source is empty, but in
Chrome it shows this error detail:
Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error.

It doesn't seem like it'd be an issue with it returning too many documents
since the forEach works with other data (and returns ~12,000 rows), so my
guess is I'm missing a fundamental piece of how this all works. I'll be
added a reduce function once I get this piece working if that makes any
difference, because ultimately I want the unique values, but for now I'm
happy just seeing them all returned including dupes.

Thanks.

--
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
------------------------------------------------------------------------
 VPRO   www.vpro.nl
------------------------------------------------------------------------

Mime
View raw message