nextapps-de / flexsearch

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

Suggestion and tokenize "forward" #411

Open Grafikart opened 9 months ago

Grafikart commented 9 months ago

I want to allow partial results while allowing multiple words. I noticed this issue #327 about suggestion. It works as expected with full words but seems to fail with partial matching.

const index = new Flexsearch.Index({ tokenize: 'forward' });

index.add(1, 'some words');
index.add(2, 'words variant');
index.add(3, 'this is a variant');
index.add(4, 'nothing');

console.clear();
console.log(index.search('word varia')); // -> [2]
console.log(index.search('word varia', { suggest: true })); // -> [ 2 ]

I would expect the last search to match 1 and 3 too (sorted it would give 2 first since it match both words). Is there an option I missed or do the algorithm used by flexsearch does not allow this kind of matching ?