Fuse icon indicating copy to clipboard operation
Fuse copied to clipboard

Export and import index

Open pe1uca opened this issue 8 months ago • 0 comments

Is there an existing issue or pull request for this?

  • [x] I have searched the existing issues and pull requests

Feature description

I'd like to store the processed index to then be able to load it instead of regenerating the data and letting Fuse recreate the index.

Desired solution

Be able to call something like this

const exportedIdx = fuse.export();

const newFuse = Fuse.import(exportedIdx);  

Alternatives considered

Manually create the values and inner properties of fuse to export/import.

I think these are the fields needed

//export
const exportedIdx = JSON.stringify({docs: fuse._docs, ...fuse.getIndex()});

// import
fuse = new Fuse();
const idxData = JSON.parse(exportedIdx);
fuse._docs = idxData.docs;
fuse.getIndex().setIndexRecords(idxData.records);
fuse.getIndex().setKeys(idxData.keys);

Additional context

No response

pe1uca avatar May 01 '25 20:05 pe1uca