Skip to content

Bulk GET

Jens Alfke edited this page Oct 24, 2013 · 3 revisions

_bulk_get is a nonstandard (i.e. non-CouchDB) addition to the sync API. It improves performance of client pull replications, by allowing the client to request multiple documents in one request. The usual CouchDB API for bulk gets -- a POST to _all_docs with an array of docIDs -- isn't suitable for the replicator because there's no way to specify which specific revisions are needed, the response doesn't contain the revision history, and attachments can only be encoded inline not as MIME multipart.

Request

POST /db/_bulk_get

URL Query Parameters

  • ?revs=true: Each returned revision body will include its revision history as a _revisions property.
  • ?attachments=true: Attachments will be included in the response.

Request Body

A JSON object with a property "docs" whose value is an array of objects, each describing a revision to return. Each of these objects has properties "id", "rev", and optionally "atts_since".

Example:

    {"docs": [
        {"id": "somedoc", "rev": "2-cafebabe", "atts_since": [12,...]},
        {"id": "otherdoc", "rev": "5-bedbedbe"}, ...
    ]}

Response

The response is of type multipart/related. Each part contains one document revision. The ordering is the same as in the array in the request.

Each revision itself is encoded as multipart, in the same format as a document GET request with attachments: the main JSON body comes first, then a body for each attachment. Each attachment body has a Content-Disposition header identifying its attachment name.

Clone this wiki locally