Querying documents containing two tags with CouchDB? <p>Consider the following documents in a CouchDB:</p> <pre><code>{ "name":"Foo1", "tags":["tag1", "tag2", "tag3"], "otherTags":["otherTag1", "otherTag2"] } { "name":"Foo2", "tags":["tag2", "tag3", "tag4"], "otherTags":["otherTag2", "otherTag3"] } { "name":"Foo3", "tags":["tag3", "tag4", "tag5"], "otherTags":["otherTag3", "otherTag4"] } </code></pre> <p>I'd like to query all documents that contain <strong>ALL</strong> (not any!) tags given as the key.</p> <p>For example, if I request using '["tag2", "tag3"]' I'd like to retrieve Foo1 and Foo2.</p> <p>I'm currently doing this by querying by tag, first for "tag2", then for "tag3", creating the union manually afterwards.</p> <p>This seems to be awfully inefficient and I assume that there must be a better way.</p> <p>My second question - but they are quite related, I think - would be:</p> <p>How would I query for all documents that contain "tag2" <strong>AND</strong> "tag3" <strong>AND</strong> "otherTag3"?</p> <p>I hope a question like this hasn't been asked/answered before. I searched for it and didn't find one.</p>