jeancroy / FuzzySearch

:mag: Fast autocomplete suggestion engine using approximate string matching
MIT License
194 stars 32 forks source link

score handling #37

Closed halukkaramete closed 2 years ago

halukkaramete commented 2 years ago

Please take a look at this screenshot.

Screen Shot 2022-03-26 at 6 00 55 AM

You may also play with the actual page: https://www.islamicity.org/quransearch/lab/scrape-sunnah-com/search/fuzzy-search-client.php and selecting the 2nd option (Search Field: FUZZYSEARCH__topic) . Type Ablution pls and you will see the same thing I posted in the screenshot

My question is...

The first match is a great bingo.. But starting with the 2nd and downward is too far away from the first word. It is better to not show such suggestions. Which settings do I need to play with so that it only shows the first one (Ablutions ) as it has a huge resemblance to what the user has typed and the others far far away from it such as ( Afflictions )?

I think this is a hard one.. Cause trying to make that view better may result sacrificing some of the good suggestions.. If this is not much possible, let me ask you something else...

Why in your demo the entire word Brain is bolded. Should not only the applicable letters to be bold? Here is the view:

Screen Shot 2022-03-26 at 6 11 20 AM

Should not we expect only the b and r and a to be in bold but not the i and n?

jeancroy commented 2 years ago

thresh_relative_to_best is what you are looking for.

For scoring setting, please read https://github.com/jeancroy/FuzzySearch#output-score-threshold As well as this https://github.com/jeancroy/FuzzySearch/blob/master/src/init.js#L19

Then what I have found is that people that are not programmer don't like "bag of letters" that much. So I bridge small gap, you can disable that behavior by setting this to 0: https://github.com/jeancroy/FuzzySearch/blob/master/src/optional/highlight.js#L9

Finally you never need to edit the JS. Just add the setting to init and it'll overwrite.

halukkaramete commented 2 years ago

Given it a second thought, I think your default settings is better than what seemed to be otherwise in the first place. So, it is better to keep that "small bridge" at 2 as opposed to 0. You can close this issue if you like,