On Thu, Feb 12, 2009 at 5:22 AM, Nicolas Clairon <[email protected]> wrote: > Thanks for your quick response. > > the line: > > curl -X POST http://localhost:5984/blog/_view/articles/by_tags -d > '{"keys":["python", "couchdb"]}' > > gives me all the articles tagged with "python" *or* "couchdb"... but > how can I handle this to have only > the articles tagged with "python" *and* "couchdb" in one shot ? You are correct, currently that feature only allows unions and not intersections, which is what want. There is talk on the dev list, http://mail-archives.apache.org/mod_mbox/couchdb-dev/200902.mbox/browser about adding such functionality to couch, but currently your app must do the work.
Regards, Jeff H > > > On Thu, Feb 12, 2009 at 11:53 AM, Jan Lehnardt <[email protected]> wrote: >> Hi, >> >> See http://wiki.apache.org/couchdb/HTTP_view_API >> >> and "POST" under "Query Options". >> >> You can POST a JSON structure with all your keys to >> a view and get all matching rows. >> >> Cheers >> Jan >> -- >> >> On 12 Feb 2009, at 11:42, Nicolas Clairon wrote: >> >>> Hi there ! >>> >>> I'm playing with tags these time and a question comes to me. >>> For exemple, I have a bunch of blog articles: >>> >>> article1 = { >>> ...snip..., >>> tags : ["couchdb", "python", "best practices"], >>> } >>> >>> article2 = { >>> ...snip..., >>> tags : ["python", "best practices"], >>> } >>> >>> article3 = { >>> ...snip..., >>> tags : ["couchdb", "best practices"], >>> } >>> >>> and a view wich emit tags: >>> >>> function(doc){ >>> if (doc.type=="article"){ >>> for (var i in doc.tags){ >>> emit( doc.tags[i], doc ) >>> } >>> } >>> } >>> >>> We can get all articles wich are tagged with "couchdb" easily: >>> >>> http://localhost:5984/blog/_view/article/by_tag?key="couchdb" >>> >>> but now, I want all articles wich are tagged with "couchdb" *and* "python" >>> (I want the article1). Is there a method to do it directly with CouchDB >>> views ? >>> Something like that : >>> >>> http://localhost:5984/blog/_view/article/by_tag?key_in=["couchdb", >>> "python"] >>> >>> For the moment, I have to do it by program, firing 2 views and merge >>> the results... >>> >>> We can also think something like this: >>> >>> http://localhost:5984/blog/_view/article/by_tag?onekey_in=["couchdb", >>> "python"] >>> >>> wich will get all articles which are tagged with "couchdb" *or* >>> "python"... >>> >>> Does it already exists in CouchDB ? >>> >>
