farzher / fuzzysort

Fast SublimeText-like fuzzy search for JavaScript.

Home Page:https://rawgit.com/farzher/fuzzysort/master/test/test.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

allow adjusting algorithm parameters

cjquines opened this issue · comments

you said it yourself that these numbers were arbitrary so what if they werent

if(uniqueBeginningIndexes > 24) score *= (uniqueBeginningIndexes-24)*10 // quite arbitrary numbers here ...

the arbitrary parts are:

  • score -= (12+unmatchedDistance) * extraMatchGroupCount, or how much we penalize having multiple groups. this could be a groupPenalty parameter, default 12?
  • score -= matchesBest[0]*10, or how much we penalize not being near the start. distancePenalty, default 10?
  • score *= (uniqueBeginningIndexes-24)*10 i have absolutely no idea what this is it seems small too so idk
  • if(isSubstring) score /= 10 maybe substringBonus?
  • if(isSubstringBeginning) score /= 10 maybe substringBeginningBonus? maybe this can just be equal to substringBonus and we don't need a param for this lol
  • score -= targetLen - searchLen this seems like it should have a multiplier around it, called lengthPenalty, something like score -= (targetLen - searchLen) * lengthPenalty default 1?

this doesn't make it any slower and i think it's pretty useful. for example, my application doesn't want to penalize distance to the start. fusejs is nice for this because it has ignoreLocation for this, but i don't like fuse due to performance issues.

hmm. i don't think it's worth the complexity. i don't think most people care about these options?

maybe if you're one of the few people who wants to change the numbers, then just change the numbers (edit the code).

what's your use case that wants to ignore location?

hmm thats fair. my use case is that im indexing over descriptions, so it's not necessarily true that what you want is in the beginning.