Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a string as "encode" doesn't work (confusing document?) #428

Open
mikecat opened this issue Feb 22, 2024 · 2 comments
Open

Setting a string as "encode" doesn't work (confusing document?) #428

mikecat opened this issue Feb 22, 2024 · 2 comments

Comments

@mikecat
Copy link

mikecat commented Feb 22, 2024

The "Index Options" section in the README.md has this as Values for encode Option:

false
"default"
"simple"
"balance"
"advanced"
"extra"
function(str) => [words]

Reading this, I thought that we can set false, one of the strings, or a function as the encode option.

However, setting false worked, but setting strings didn't work.

I tried this code on RunKit:

const FlexSearch = require("flexsearch@0.7.31")

const index = new FlexSearch.Index({
  encode: "simple",
});

index.add(0, "Lorem ipsum dolor sit amet.");

This resulted in an error:

TypeError: this.encode is not a function

at t.add in flexsearch@0.7.31/dist/flexsearch/bundle.js — line 12

@Artemis-chan
Copy link

It turns out had to set the charset field. So like

{
   charset: "latin:<encoder>"
}

@kolaente
Copy link

Tried setting it on the charset but then got the error a2.split is not a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants