Elasticsearch-js client extension for processing scroll results.
npm install elasticsearch-scrolltoend> Elasticsearch-js client extension for processing scroll results.
This module provides scrollToEnd function which allows for processing each batch while scrolling search results.
Install the package.
```
npm install --save elasticsearch-scrolltoend
Then extend the Elasticsearch API by including this plugin.
`js
'use strict';
const hosts = ['127.0.0.1'];
const apiVersion = '2.x';
const elasticsearch = require('elasticsearch');
const esScrollToEnd = require('elasticsearch-scrolltoend');
const client = new elasticsearch.Client({
hosts, apiVersion,
plugins: [ esScrollToEnd.plugin ]
});
`
Define a function for processing batches.
`js`
let batchHandler = function(res) {
console.log(res);
return Promise.resolve();
};
Start scrolling.
`jsproducts
let index = ;``
let scroll = '60s';
let scrollToEnd = client.scrollToEnd(scroll, batchHandler);
return client.search({index, scroll, search_type: 'scan'}).then(scrollToEnd);