You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
524B

  1. const fs = require('fs');
  2. const elasticlunr = require('elasticlunr');
  3. const start = process.hrtime();
  4. const elapsed = (msg) => {
  5. let now = process.hrtime(start);
  6. console.info('[ %ds %dms elapsed ] %s', now[0], now[1] / 1000000, msg)
  7. };
  8. const inputFile = '../sample2.json';
  9. //const inputFile = 'elasticlunr-wiki-index.json';
  10. elapsed('reading file ...');
  11. let rawData = fs.readFileSync(inputFile);
  12. elapsed('parsing json ...');
  13. let indexData = JSON.parse(rawData);
  14. elapsed('indexData.length = ' + indexData.length);