By combining the POST
method to a given view
with the include_docs=true
query argument you
can obtain multiple documents from a database. The result is
more efficient than using multiple
Section 6.2, “GET /db/doc
”
requests.
For example, sending the following request for ingredients matching “claret” and “clear apple juice”:
POST http://couchdb:5984/recipes/_design/recipes/_view/by_ingredient?include_docs=true Content-Type: application/json { "keys" : [ "claret", "clear apple juice" ] }
Returns the full document for each recipe:
{ "offset" : 6324, "rows" : [ { "doc" : { "_id" : "Scotchcollops", "_rev" : "1-bcbdf724f8544c89697a1cbc4b9f0178", "cooktime" : "8", "ingredients" : [ { "ingredient" : "onion", "ingredtext" : "onion, peeled and chopped", "meastext" : "1" }, ... ], "keywords" : [ "cook method.hob, oven, grill@hob", "diet@wheat-free", "diet@peanut-free", "special collections@classic recipe", "cuisine@british traditional", "diet@corn-free", "diet@citrus-free", "special collections@very easy", "diet@shellfish-free", "main ingredient@meat", "occasion@christmas", "meal type@main", "diet@egg-free", "diet@gluten-free" ], "preptime" : "10", "servings" : "4", "subtitle" : "This recipe comes from an old recipe book of 1683 called 'The Gentlewoman's Kitchen'. This is an excellent way of making a rich and full-flavoured meat dish in a very short time.", "title" : "Scotch collops", "totaltime" : "18" }, "id" : "Scotchcollops", "key" : "claret", "value" : [ "Scotch collops" ] }, { "doc" : { "_id" : "Standpie", "_rev" : "1-bff6edf3ca2474a243023f2dad432a5a", "cooktime" : "92", "ingredients" : [ ... ], "keywords" : [ "diet@dairy-free", "diet@peanut-free", "special collections@classic recipe", "cuisine@british traditional", "diet@corn-free", "diet@citrus-free", "occasion@buffet party", "diet@shellfish-free", "occasion@picnic", "special collections@lunchbox", "main ingredient@meat", "convenience@serve with salad for complete meal", "meal type@main", "cook method.hob, oven, grill@hob / oven", "diet@cow dairy-free" ], "preptime" : "30", "servings" : "6", "subtitle" : "Serve this pie with pickled vegetables and potato salad.", "title" : "Stand pie", "totaltime" : "437" }, "id" : "Standpie", "key" : "clear apple juice", "value" : [ "Stand pie" ] } ], "total_rows" : 26484 }