Fetch Documents by Multiple DocIDs in One Call

0 votes
I it possible to retrieve multiple docs at once by DocId? Say, for instance, I have three DocIds and I want to grab the document for each one. Can I do this in one API call?

FindDocumentsByQuery() comes close; it allows me to retrieve multiple docs by key/value simultaneously. But I can't search by DocId this way :(  Perhaps I can slightly modify FindDocumentsByQuery??
asked May 6, 2014 in App42 Cloud API-BaaS by David Harrison Turpi (23 points)

1 Answer

+1 vote
Best answer

Hi David, Yes you can retiive all documents by passing the docIds  in INLIST Operator.

Here is sample code snippet for  JAVA  SDK.You can do same for all others SDKs as well.


ArrayList<String> docIds = new ArrayList<String>();
docIds.add("Doc Id 1");
docIds.add("Doc Id 2");
docIds.add("Doc Id 3");
Query myQuery  = QueryBuilder.build("_id", docIds , Operator.INLIST);
Storage storageObj = storage.findDocumentsByQuery("Your DB",
  "Your Collection Name", myQuery );
answered May 7, 2014 by naresh (350 points)
selected May 7, 2014 by David Harrison Turpi
Fantastic, thanks! I'll look into this. We're using Cocos2d-x, by the way.
Ok great  :)
What IF I wanted to do the same thing( using javascript sdk) except by a "key value" rather than doc ids?
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com