Improve search results by checking query against package id and name (#2232 - #1556)
Short summary
This change looks to improve results when searching packages on the search bar. Aims to improve search results, fixes #2232, fixes #1556.
This modification does two things:
- Compare search queries directly with the component name or the component id. If there is either an exact match or partial match (a sub-string). It will improve its score significantly to help it bump it up to the top.
- I based this scores similarly to what the bult-in flatpak app does here: https://github.com/flatpak/flatpak/blob/b5f9d6e18a6c5ad54b85691a48c1b3140154faae/app/flatpak-builtins-search.c#L303
- If there are multiple tokens, add an extra token that consist of all joined tokens, which aims to compare directly to name or id. (for example "libre office" would have the tokens "libre, "office" and will add third extra token being "libreoffice".
Tests
Recreated search queries with three apps: CherryTree, Gnu Cash, and Libre Office:
- Searching for "Libre Office" in various forms should give you more varied results given the new scores. Searching for "Libre" should show Libre Office in the list.
- Searching for "Gnu Cash" and "Cash" will now show the Gnu Cash app and other that match the substring (as opposed of not showing anything or not showing the app itself among others)
- Searching for "tree" will eventually show the CherryTree app below properly (as opposed of not showing it).
I think this change should bring overall better search result especially when searching for name directly for some apps.
Hm.... Searching for "Cherry" still doesn't show CherryTree app for me:
@lenemter Huh, how odd, just tested it and it shows for me.
Maybe I'm doing something wrong wit my setup. I will check to ensure that I'm using the correct installed app.
EDIT: Just checked and ensured its the updated app in the correct branch. I can see the CherryTree app. Not sure what I could do to ensure it shows properly or not.