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:
@@ -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
|
||||
|
Reference in New Issue
Block a user