nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.53k stars 491 forks source link

Bug with importing encoders in node #351

Closed Timpan4 closed 2 years ago

Timpan4 commented 2 years ago

I'm getting this issue when trying to import the "advanced" encoders:

image

Doesn't matter if i use import or require, the error is comming from within the package.

My code:

import advanced from 'flexsearch/dist/module/lang/latin/advanced.js';

const data = new Document({
    encode: advanced,
    preset: 'match',
    tokenize: 'full',
    index: ['Key', 'Value', 'UserId', 'Name', 'ProfilePicture', 'Alerting', 'Priority', 'IsExternal'],
    store: true,
    id: 'id',
    resolution: 1,
    depth: 10
});
ts-thomas commented 2 years ago

It looks like you are using ES6-modules in Nodejs-Module-Project. Here is how to use in Node.js, please check:

https://github.com/nextapps-de/flexsearch#nodejs

You don't need to import "advanced" encoder, because there are already included in the Nodejs-Bundle. Just use charset: "latin:advanced" as an option.