0

I'd like to do a bulk query to cloudant db.

By supplying a list of _ids (primary key), and have db return any documents with matching _ids.

This is working as shown below. But I'd like to return _id, _rev and field_name also. Is there a way to do this without using include_docs=true?

Request:

http://{db-host}/{db-name}/_all_docs?keys=["1e0a2d30d18d95b9bcc05d92c8736eab","181687d2f16debc10f9e365cc4002371"]

Response:

{
  "total_rows": 3,
  "rows": [{
    "id": "1e0a2d30d18d95b9bcc05d92c8736eab",
    "key": "1e0a2d30d18d95b9bcc05d92c8736eab",
    "value": {
      "rev": "1-a26b67f478e4f3f8fd49779a66fc7949"
    }
  }, {
    "id": "181687d2f16debc10f9e365cc4002371",
    "key": "181687d2f16debc10f9e365cc4002371",
    "value": {
      "rev": "1-7338901ca1c5c06ef81a6971aa6e8f9d"
    }
  }]
}
2
  • You've already got id and rev. Commented May 17, 2016 at 12:16
  • I want field_name also. Commented May 17, 2016 at 12:34

2 Answers 2

2

No. The index of _all_docs does not contain the field_name data. The only way to get it using this view is with include_docs.

Otherwise you will have to write (and index) your own view that emits what you want.

map: function(doc) {
    emit(doc._id, { _id: doc._id, _rev: doc._rev, field_name: doc.field_name });
}
Sign up to request clarification or add additional context in comments.

Comments

0

An alternative to using include_docs or manually populating all fields is to emit docs as values in a view, like that:

emit(doc._id, doc);

1 Comment

Quoting the documentation: "It is not recommended to emit the document itself in the view. Instead, to include the bodies of the documents when requesting the view, request the view with ?include_docs=true."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.