-
-
Notifications
You must be signed in to change notification settings - Fork 782
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 returns no results #624
Labels
Comments
Nope, I was wrong. This is a bug on me. Full working code: // build step
const csvDatabaseFileName = "database.csv";
const fuseIndexName = "fuse-index.json";
const jsonDatabaseName = "database.json";
const csvString = fs.readFileSync(csvDatabaseFileName).toString();
// See https://www.papaparse.com/docs
const papaJson = Papa.parse(csvString, {
header: true,
dynamicTyping: true
});
const headers = papaJson["meta"]["fields"];
const json = papaJson["data"];
fs.writeFileSync(jsonDatabaseName, JSON.stringify(papaJson));
// See https://fusejs.io/api/indexing.html
const fuseIndex = Fuse.createIndex(headers, json);
fs.writeFileSync(fuseIndexName, JSON.stringify(fuseIndex.toJSON())); // index.html (within script tag)
async function start() {
const fuseIndexJson = await fetch(fuseIndexName)
.then(response => response.json());
const fuseIndex = Fuse.parseIndex(fuseIndexJson);
const json = await fetch(jsonDatabaseName)
.then(response => response.json());
const options = {
includeScore: true,
keys: json["meta"]["fields"]
};
const fuse = new Fuse(json["data"], options, fuseIndex);
console.log(fuse.search("<pattern>"));
}
start(); Summary
|
Sorry about that and thanks for this great library |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same as #524. Copying over from there with slight tweaks.
Describe the bug
Empty results when loading precomputed index.
Version
6.5.3
Is this a regression?
don't know
🔬Minimal Reproduction
Additional context
The last print shows that
docs
,keys
,records
is empty, if loaded from the precomputed index.The text was updated successfully, but these errors were encountered: