mGetDocument

// Using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .mGetDocument(['doc1', 'doc2'], function (error, result) {
    // callback called once the mGet operation has completed
    // => the result is a JSON object containing the raw Kuzzle response
  });

// Using promises (NodeJS only)
kuzzle
 .collection('collection', 'index')
 .mGetDocument()
 .then(result => {
   // promise resolved once the mGet operation has completed
   // => the result is a JSON object containing the raw Kuzzle response
 });
String[] documentIds = new String[]{"doc1", "doc2"};

kuzzle
  .collection("collection", "index")
  .mGetDocument(documentIds, new ResponseListener<JSONObject>() {
    @Override
    public void onSuccess(JSONObject object) {
      // callback called once the mGet operation has completed
      // => the result is a JSON object containing the raw Kuzzle response
    }

    @Override
    public void onError(JSONObject error) {
      // Handle error
    }
  });
<?php

use \Kuzzle\Kuzzle;

$kuzzle = new Kuzzle('localhost');
$dataCollection = $kuzzle->collection('collection', 'index');

try {
  $result = $dataCollection->mGetDocument(['doc1', 'doc2']);
}
catch (ErrorException $e) {

}

Callback response:

{
  "hits": [
    {"_id": "doc1", "first": "document"},
    {"_id": "doc2", "second": "document"}
  ],
  "total": 2
}

Get multiple Documents according to the provided document IDs.


mGetDocument(documentIds, [options], callback)

ArgumentsTypeDescription
documentIdsString[]Array of IDs of documents to retrieve
optionsJSON ObjectOptional parameters
callbackfunctionCallback handling the response

Options

OptionTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue

Callback response

Resolves to a JSON object containing the raw Kuzzle response.