1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-28 14:29:01 +02:00
Files
flexsearch/example/nodejs-esm/document-worker-export-import/config.primaryTitle.js
2025-03-20 21:58:45 +01:00

30 lines
723 B
JavaScript

import { Encoder, Charset } from "flexsearch/esm";
import EnglishPreset from "flexsearch/esm/lang/en";
import { promises as fs } from "fs";
(async function(){
await fs.mkdir("./export/").catch(e => {});
}());
export default {
tokenize: "forward",
encoder: new Encoder(
Charset.LatinBalance,
EnglishPreset,
{
normalize: function(str){
return str.toLowerCase();
},
filter: false,
minlength: 3
}
),
export: async function(key, data){
await fs.writeFile("./export/" + key, data, "utf8");
},
import: async function(file){
return await fs.readFile("./export/" + file, "utf8");
}
};