From cfb74c7bdb83c378dcf5ec14fd444e6ff097f839 Mon Sep 17 00:00:00 2001 From: George Date: Fri, 26 Jun 2020 09:03:53 -0400 Subject: [PATCH] change search ordering to prefer name and summary matches Search in F-Droid Client is currently not doing any ranking. This adds a very simple ranking scheme by putting apps matching in the name field before summary matches before everything else. The fallback sort order (and the order for an empty search query) is still by last updated. The alphabetical order was removed as sorting alphabetically in 3 sublists is confusing and doesn't really add any extra value. Multiple terms need to all have a match in the field for a result to be ranked in the appropriate match category (name, summary, everything else) The generated sortOrder query when searching for "email client" looks like this: case when fdroid_app.name like '%email%' and fdroid_app.name like '%client%' then 1 when fdroid_app.summary like '%email%' and fdroid_app.summary like '%client%' then 2 else 3 end, fdroid_app.lastUpdated desc --- .../java/org/fdroid/fdroid/views/apps/AppListActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java b/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java index 0e55c382a..3863adfa8 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/apps/AppListActivity.java @@ -186,8 +186,8 @@ public class AppListActivity extends AppCompatActivity implements LoaderManager. StringBuilder titleCase = new StringBuilder(String.format("%s like '%%%s%%'", NAME_COL, terms[0])); StringBuilder summaryCase = new StringBuilder(String.format("%s like '%%%s%%'", SUMMARY_COL, terms[0])); for (int i = 1; i < terms.length; i++) { - titleCase.append(String.format(" or %s like '%%%s%%'", NAME_COL, terms[i])); - summaryCase.append(String.format(" or %s like '%%%s%%'", SUMMARY_COL, terms[i])); + titleCase.append(String.format(" and %s like '%%%s%%'", NAME_COL, terms[i])); + summaryCase.append(String.format(" and %s like '%%%s%%'", SUMMARY_COL, terms[i])); } return String.format("case when %s then 1 when %s then 2 else 3 end, %s",