hzeller/stuff-org

search string matching issue

Closed this issue · 1 comments

search for "led" and you'll notice that bin 968 is in the gallery view.
this is incorrect, because this part is not an LED.
instead it seems to match a word in the notes field which is the word "sealed".

why not match from the beginning of words only?

just a suggestion!

-rolf

This is actually working as intended. You might have noticed for instance, that the result was very much at the bottom.

Words are scored by distance how far they are from the beginning - so if a word shows up in the middle of a larger word and does not start with it, it gets penalized.
So that particular item is scored very far at the bottom (and yeah, it is the last item in the list). The first items in the list are all LEDs, so this is working perfectly. And exact matches are even getting boosted (so not only a prefix of a word, but a word that is exactly "led").

We can't just use beginning of words, as you often want to search for substrings or don't really know how it is written (e.g. you are search for some 74HCT374 ? You likely would start with searching for 374 and look what comes up). The scoring makes sure to still sort the things at the top that are likely the most useful.

And in practice we see that the result ordering actually works quite nicely.