Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ucyo opened this issue Dec 20, 2020 · 3 comments
Closed

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

ucyo opened this issue Dec 20, 2020 · 3 comments

Comments

@ucyo
Copy link

ucyo commented Dec 20, 2020

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.

@github-actions
Copy link

github-actions bot commented Feb 1, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Feb 1, 2021
@ucyo
Copy link
Author

ucyo commented Feb 2, 2021

:bump:

@github-actions github-actions bot closed this as completed Feb 8, 2021
@GonzaloZiadi
Copy link

I'm seeing this same issue in 6.5.3. I can't get Fuse to work using a precomputed index. Works fine when doing const fuse = new Fuse(json, options);

dbaynard added a commit to dbaynard/Fuse that referenced this issue Oct 16, 2024
It is far from obvious, here and in the examples, how to use this function, and if supplied an incorrect argument it errs, silently.

The simplest way to avoid the confusion is to document the change. Narrowing the type is the first part of that.

See krisk#524 and krisk#624 for people bitten by this.
dbaynard added a commit to dbaynard/Fuse that referenced this issue Oct 17, 2024
It is far from obvious, here and in the examples, how to use this function, and if supplied an incorrect argument it errs, silently.

The simplest way to avoid the confusion is to document the change. Narrowing the type is the first part of that.

See krisk#524 and krisk#624 for people bitten by this.
dbaynard added a commit to dbaynard/Fuse that referenced this issue Oct 17, 2024
Narrowing the type of the parameter from `any` makes it obvious that the
input is an `Object`, rather than a `String`.

With the `any` type as input, it was not obvious how to use this
function.

See krisk#524 and krisk#624 for people bitten by this.
krisk pushed a commit that referenced this issue Feb 3, 2025
Narrowing the type of the parameter from `any` makes it obvious that the
input is an `Object`, rather than a `String`.

With the `any` type as input, it was not obvious how to use this
function.

See #524 and #624 for people bitten by this.
krisk pushed a commit that referenced this issue Feb 3, 2025
Narrowing the type of the parameter from `any` makes it obvious that the
input is an `Object`, rather than a `String`.

With the `any` type as input, it was not obvious how to use this
function.

See #524 and #624 for people bitten by this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants