incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
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.
   startkey=["by_word","the"]&endkey=["by_word","the",{}]
or
   startkey=["by_id","mydoc1"]&endkey=["by_id","mydoc1",{}]

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

Mime
View raw message