Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB multiple tags

Tags:

couchdb

Is there any way to have multiple tag search implemented in CouchDB? I have documents (posts) each with multiple tags. I need to find posts that have been tagged with an arbitrary set of tags. How do I do it? I could of course do it with multiple calls to a view which gives me the documents for a tag and then sort it out in my app but I wanted to know if there was a way to achieve the same in the CouchDB view land.

like image 272
Vagmi Mudumbai Avatar asked Sep 28 '09 05:09

Vagmi Mudumbai


1 Answers

In the more recent versions of CouchDB, you can POST to a view with a JSON document called keys, which allows for multi-key lookup. The structure would look something like this:

{"keys": ["first_tag", "second_tag", "third_tag"]}

This could be POSTed to a view that you have that is emitting tags for its respective keys.

This and other querying options are documented here.

like image 100
Ryan Duffield Avatar answered Oct 03 '22 09:10

Ryan Duffield