scroll

// Using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .scroll(scrollId, {scroll: '1m'}, function (err, searchResult) {
    searchResult.getDocuments().forEach(function (document) {
      console.log(document.toString());
    });
  });

// Using promises (NodeJS only)
kuzzle
  .collection('collection', 'index')
  .scrollPromise(scrollId, {scroll: '1m'})
  .then(searchResult => {
    searchResult.getDocuments().forEach(document => {
      console.log(document.toString());
    });
  });
Options opts = new Options();
opts.setScroll("1m");

kuzzle
  .collection("collection", "index")
  .scroll(scrollId, opts, new ResponseListener<SearchResult>() {
    @Override
    public void onSuccess(SearchResult searchResult) {
      for (Document doc : searchResult.getDocuments()) {
        // Get documents
      }

      searchResult.getTotal(); // return total of documents returned

      searchResult.getAggregations(): // return a JSONObject representing the aggregations response
    }

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

use \Kuzzle\Kuzzle;
use \Kuzzle\Document;
use \Kuzzle\Util\SearchResult;

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

try {
  $searchResult = $dataCollection->scroll($scrollId, ['scroll' => '1m']);

  // $searchResult instanceof SearchResult
  $searchResult->getTotal();

  foreach($searchResult->getDocuments() as $document) {
    // $document instanceof Document
  }

  // return an array representing the aggregations response
  $searchResult->getAggregations();
}
catch (ErrorException $e) {

}

Returns a SearchResult object containing the next page of the scroll session, and the scrollId to be used by the next scroll action.
A scroll session is always initiated by a search action by using the scroll argument; more information below.


scroll(scrollId, [options], callback)

ArgumentsTypeDescription
scrollIdstringThe "scrollId" provided with the last scroll response or from the initial search request if it is the first scroll call
optionsJSON objectOptional parameters
callbackfunctionCallback handling the response

Options

OptionTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue
scrollstringRe-initializes the scroll session timeout to its value. If not defined, the scroll timeout is defaulted to a Kuzzle configurationundefined

Callback response

Resolves to an instantiated SearchResult object.