krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
18.1k stars 766 forks source link

[feature]: what about adding a maxMatchSize option? #314

Closed dabuside closed 5 years ago

dabuside commented 5 years ago

When searching in a large object, there may be too many results. Adding a maxMatchSize option would reduce the perform issue by early returns.

heyimalex commented 5 years ago

It wouldn't make a huge difference without re-architecting some things. Ultimately you need to score all of the entries to find out the top entries, and that's where all the performance critical work is.

krisk commented 5 years ago

Agreed, @heyimalex.

dabuside commented 5 years ago

It wouldn't make a huge difference without re-architecting some things. Ultimately you need to score all of the entries to find out the top entries, and that's where all the performance critical work is.

It may not need to score all of the entries, just to find a limit number of the result that meets the threshold(early returns, left the rest unvisited).

I've found the limit option on code, but it's not used. https://github.com/krisk/Fuse/blob/fe1ff83645a55b6ea9f9488893a32495c132529f/src/index.js#L100-L102

heyimalex commented 5 years ago

@dabuside You're right that it'd be possible, but how often would it be used? The vast majority of people want the best matches, not the first x matches that crossed the threshold.

That code you linked runs after scoring.

dabuside commented 5 years ago

@dabuside You're right that it'd be possible, but how often would it be used? The vast majority of people want the best matches, not the first x matches that crossed the threshold.

That code you linked runs after scoring.

oops. You're right.