1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-08-11 08:34:44 +02:00

proper light/compact bundle

This commit is contained in:
Thomas Wilkerling
2025-03-20 11:53:22 +01:00
parent b2c79cfd0e
commit 84c7a08e9e
60 changed files with 1591 additions and 2238 deletions

View File

@@ -1,13 +1,18 @@
const { Worker: WorkerIndex } = require("flexsearch");
// you will need to keep the index configuration
// they will not export, also every change to the
// configuration requires a full re-index
const config = {
tokenize: "forward",
config: __dirname + "/config.js"
};
(async function(){
// create a simple index which can store id-content-pairs
// and await (!) for the worker response
let index = await new WorkerIndex({
tokenize: "forward",
config: __dirname + "/config.js"
});
let index = await new WorkerIndex(config);
// some test data
const data = [
@@ -39,19 +44,16 @@ const { Worker: WorkerIndex } = require("flexsearch");
// EXPORT
// -----------------------
await index.export(function(){
// do nothing here
});
index = await new WorkerIndex({
tokenize: "forward",
config: __dirname + "/config.js"
});
await index.export();
// -----------------------
// IMPORT
// -----------------------
// create the same type of index you have used by .export()
// along with the same configuration
index = await new WorkerIndex(config);
await index.import();
// perform query