couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ross Bates <rba...@gmail.com>
Subject getting unique set of document id's
Date Sat, 04 Jul 2009 18:48:10 GMT
Hi All - finally got up an running with 0.9.0 and have been experimenting
with the POST {"keys": ["key1", "key2", ...]} feature and have a question

Take the typical example of a set of blog posts which can be tagged with
1...n tags. Pretend I want to find all posts tagged with both "foo" and
"bar".

A simple map would look something like this

function(doc) {
  for(i in doc.tags) {
      emit(doc.tags[i], doc._id);
    }
}

So now when I post {"keys": ["foo", "bar"]} to the view I get all the
documents tagged "foo", "bar", and also duplicates for any document that is
tagged with both.

Is the best option to deduplicate the doc._id on the client and resubmit to
all docs, or can this be handled in a reduce function?

Thank you for any help!

Ross

-----
@rossbates
rossbates.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message