1.1.0 • Published 12 months ago

scrollgenerator v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

Scroll Generator

is lite and quick set up package to scroll over elastic search index built using built in node js generator

How it work

all you have to do to scroll over an index is to give two params and done
- first import your elastic search client
example :
import client from "../libs/elasticsearch";
- import scrollOverIndex :
import scrollOverIndex from "scrollgenerator";
- write your optional options parameter
let options = {
  client: client,
  index: "my_index",
  sort: [
    {
      "my_field": {
        order: "asc",
      },
    },
  ],
  query: {
    match_all: {},
  },
  size: 500,
};
  • note : All of these options are required exepct size (default = 500)
  • finally write executable code with the imported scrollOverIndex function and scrollRun callback
async function main() {
  await scrollOverIndex(options, scrollRun);
  console.log("scrolling over index done :)");
}

main();
  • the scrollRun will run in evey batch of hits
  • example of scrollRun callback :
async function scrollRun(result) {
  for (let item of result.hits.hits) {
    console.log(`data length :|| ${result.hits.total.value}`);
    console.log(item);
  }
  return;
}
1.1.0

12 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago