couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <>
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.

Van: Matthew Woodward []
Verzonden: donderdag 20 januari 2011 7:21
Onderwerp: Re: Writing View to Get Unique Values in Arrays Across Documents

On Wed, Jan 19, 2011 at 3:48 PM, Jan Lehnardt <> wrote:


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.witnesses !=
'[]') { doc.witnesses.forEach(function(witness) { emit(, null);});

So that outputs 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.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.


Matthew Woodward / Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.

View raw message