Skip to content

Precomputed index is returning no results. Different usage maybe? #524

@ucyo

Description

@ucyo

Describe the bug

Empty results when loading precomputed index.

Version

6.4.3

Is this a regression?

dunno

🔬Minimal Reproduction

const Fuse = require('fuse.js');
const fs = require('fs');

const search_options = {
  includeScore: true,
  useExtendedSearch: true,
  keys: ['title']
}

callback = function(err) {
  if (err) throw err;
  console.log('Write complete');
};

const datasets = [{"title":2},{"title":3}];
var myIndex = Fuse.createIndex(search_options.keys, datasets);

fs.writeFile('./index.json', JSON.stringify(myIndex.toJSON()), callback);

//var myIndex = Fuse.parseIndex('./index.json');

const fuse = new Fuse(datasets, search_options, myIndex);

var search_term = process.argv[2];
var result = fuse.search(search_term);
console.log(result);
console.log(myIndex);

Additional context

The last print shows that docs, keys, records is empty, if loaded from the precomputed index.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions