Skip to main content
100%

save lunr.js state

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Apr 18, 2015
Created on Apr 18, 2015

This example demonstrates how to save the complete internal state of a lunr.js search index to a downloadable JSON file. The code defines a console utility that serializes the index using `JSON.stringify` with pretty-printing, then creates a Blob with `text/json` MIME type. It uses the browser’s `URL.createObjectURL` to generate a temporary download link, which is programmatically clicked via a `MouseEvents`-dispatched event. The final line calls `lunr_index.toJSON()` to capture the index’s serialized data into `_indexed.json`. This approach relies on native browser APIs for file generation rather than external libraries.

AI-generated description

Similar vizzes