couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <>
Subject Re: multiple key word count query problem
Date Tue, 21 Jul 2009 07:27:36 GMT
On Sun, Jul 19, 2009 at 08:06:44PM -0700, Tommy Chheng wrote:
> the problem with having two views:
> If i had two views, one for [word, doc] => count and [doc, word] =>  
> count; it would be re-doing the same word counting function twice.

It's usually not a problem, but if it is for some reason (i.e. your view
calculation is especially expensive) then you could do:

  for (var word in wors) {
    emit(["by_word", word, doc._id]);
    emit(["by_id", doc._id, word]);

Then this single view could be queried for e.g.

I would expect a single view like this to be a bit larger than two separate
views, because of the extra tags being stored.

View raw message