nextapps-de / flexsearch

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

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

Open mikecat opened 8 months ago

mikecat commented 8 months ago

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 commented 5 months ago

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

{
   charset: "latin:<encoder>"
}
kolaente commented 1 month ago

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