krisk / Fuse

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

feat(scoring): field length norm weight #592

Closed adlerfaulkner closed 2 years ago

adlerfaulkner commented 2 years ago

Add advanced config option fieldNormWeight to allow for customizability in how much field-length norm effects scores.

adlerfaulkner commented 2 years ago

Hello!

For my use case I felt like the field-length norm factor was boosting short results too much compared to other longer yet still relevant results. I didn't want to turn field-length norm off completely so I added an option to tone down (or up) the field-length norm function.

The previous field-length norm function is 1/srqt(x) where x is the number of words in the field. This PR changes that function to 1/x^(0.5*fieldNormWeight). fieldNormWeight defaults to 1, making the functions equivalent. However, changing fieldNormWeight to 0.5 produces a "smoother" curve, lessening the effects of field-length norm on the score of long fields.

krisk commented 2 years ago

This is excellent. Thanks!

krisk commented 2 years ago

mm had to do a manual merge. Closed by a9e00804497a1bfd7a94040520417825c085c945

krisk commented 2 years ago

Can you create a separate PR to add the necessary documentation? Thanks!

adlerfaulkner commented 2 years ago

Yes, will get to that tomorrow :)

adlerfaulkner commented 2 years ago

@krisk https://github.com/krisk/Fuse/pull/603