farzher / fuzzysort

Fast SublimeText-like fuzzy search for JavaScript.
https://rawgit.com/farzher/fuzzysort/master/test/test.html
MIT License
3.96k stars 159 forks source link

Understanding what are expected results #126

Closed greggman closed 7 months ago

greggman commented 11 months ago

I was looking for a solution where if I search for 2 or more words, items with those exact 2 words appear before items without those 2 words. Items with either of those 2 works appear next. Only after do items with neither of those 2 works but some combination of their letters appear. That seems, at least to me, what a user would expect.

If my data is

Betty James
Andy Smith
James Smith
Smith James
Dave Miller
Jim Samson

If I search for "James Smith" I'd expect to see this order

James Smith   # perfect match
Smith James   # same 2 words
Betty James   # at least one word
Andy Smith    # at least one word (maybe swapped with previous)
Jim Samson    # probably #5 because the 2 words start with the same letter and 6 letters same
Dave Miller   # 5 letters same

Testing on the demo site here

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

If I search for "human" I see several matches

Screenshot 2023-11-17 at 10 49 28

If I search for "web" I see tons of matches (though I think I'd expect matches with "web" as a single word to appear first and they don't)

Screenshot 2023-11-17 at 10 49 48

If I search for "human web" then no answers appear with either word

Screenshot 2023-11-17 at 10 49 58

Am I misunderstanding what this library is supposed to do?

farzher commented 11 months ago

Am I misunderstanding what this library is supposed to do?

yes. https://github.com/farzher/fuzzysort/issues/96#issuecomment-1076422766

i agree with your example but that's just not the use case i guess. not sure if i could make that work without breaking the intended use case of quickly looking up files