Problem or enhancement idea
mod-flexsearch v4's new lazyLoad option (added in gethinode/mod-flexsearch@caaa1fb) fetches a JSON array of documents on the visitor's first search interaction and calls index.add(doc) per document. Tokenization runs in the browser. On large sites this is acceptable but not the fastest available option.
Proposed solution
FlexSearch v0.8 supports Document.export() / Document.import() for serialized indices. The proposal:
- At build time, serialize the index via
Document.export() and emit the chunked JSON output FlexSearch produces (per field, per stage: reg, tag, doc, map).
- Switch the lazy runtime in
flexsearch.index.js to fetch and import() instead of fetch and per-document add().
Estimated wins: faster first search (no client-side tokenization) and a smaller transferred payload (~40-50% per the FlexSearch docs).
Alternatives
Keep the current JSON-array + add() path. It is simpler and version-independent of FlexSearch's serialization format, at the cost of CPU on first search.
Additional context
lazyLoad introduced in gethinode/mod-flexsearch@caaa1fb (feat: add lazyLoad option to fetch the search index on demand).
- The plan for the original lazy-load work flagged this as the next perf step.
- Implementation needs a Node-side step at build time to invoke
export() and a corresponding import() in the client.
- Couples mod-flexsearch to the FlexSearch v0.8.x serialization format.
Problem or enhancement idea
mod-flexsearchv4's newlazyLoadoption (added in gethinode/mod-flexsearch@caaa1fb) fetches a JSON array of documents on the visitor's first search interaction and callsindex.add(doc)per document. Tokenization runs in the browser. On large sites this is acceptable but not the fastest available option.Proposed solution
FlexSearch v0.8 supports
Document.export()/Document.import()for serialized indices. The proposal:Document.export()and emit the chunked JSON output FlexSearch produces (per field, per stage:reg,tag,doc,map).flexsearch.index.jsto fetch andimport()instead of fetch and per-documentadd().Estimated wins: faster first search (no client-side tokenization) and a smaller transferred payload (~40-50% per the FlexSearch docs).
Alternatives
Keep the current JSON-array +
add()path. It is simpler and version-independent of FlexSearch's serialization format, at the cost of CPU on first search.Additional context
lazyLoadintroduced in gethinode/mod-flexsearch@caaa1fb (feat: add lazyLoad option to fetch the search index on demand).export()and a correspondingimport()in the client.