From 9583147c585dbae3812d435355f4b09d30c3cf0f Mon Sep 17 00:00:00 2001 From: aming Date: Tue, 11 Jun 2024 14:11:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(app-search):=E5=BA=94=E7=94=A8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=94=AF=E6=8C=81=E5=8E=BB=E6=8E=89=E7=A9=BA=E6=A0=BC?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/appdata/app-info-table.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libsearch/appdata/app-info-table.cpp b/libsearch/appdata/app-info-table.cpp index 2a5f968..12a7945 100644 --- a/libsearch/appdata/app-info-table.cpp +++ b/libsearch/appdata/app-info-table.cpp @@ -494,12 +494,10 @@ bool AppInfoTable::query(ApplicationInfoMap &infoMap, const ApplicationPropertie field.append(ApplicationPropertyHelper(ApplicationProperty::Property::DesktopFilePath).dataBaseField() + ","); } field.append(ApplicationPropertyHelper(ApplicationProperty::Property::LocalKeywords).dataBaseField()); - QString condition; for (const ApplicationProperty::Property prop: restrictions.keys()) { condition.append(ApplicationPropertyHelper(prop).dataBaseField() + "=? AND "); } - QString keywordCondition; QString findWithLocalKeywords = "((select count(*) from (" "WITH RECURSIVE split(str, rest) AS " @@ -513,9 +511,9 @@ bool AppInfoTable::query(ApplicationInfoMap &infoMap, const ApplicationPropertie "SELECT str FROM split WHERE lower(str)=?)) <> 0)"; for(const QString& keyword : keywords) { if(keyword.size() < 2) { - keywordCondition.append(QString("(ifnull(LOCAL_NAME, '') like ? or ifnull(NAME_EN, '') like ? or ifnull(NAME_ZH, '') like ? or ifnull(FIRST_LETTER_OF_PINYIN, '') like ? or %0) AND").arg(findWithLocalKeywords)); + keywordCondition.append(QString("(ifnull(LOCAL_NAME, '') like ? or ifnull(replace(LOCAL_NAME,' ',''), '') like ? or ifnull(NAME_EN, '') like ? or ifnull(replace(NAME_EN,' ',''), '') like ? or ifnull(NAME_ZH, '') like ? or ifnull(replace(NAME_ZH,' ',''), '') like ? or ifnull(FIRST_LETTER_OF_PINYIN, '') like ? or ifnull(replace(FIRST_LETTER_OF_PINYIN,' ',''), '') like ? or %0) AND").arg(findWithLocalKeywords)); } else { - keywordCondition.append(QString("(ifnull(LOCAL_NAME, '') like ? or ifnull(NAME_EN, '') like ? or ifnull(NAME_ZH, '') like ? or ifnull(FIRST_LETTER_OF_PINYIN, '') like ? or ifnull(PINYIN_NAME, '') like ? or %0) AND").arg(findWithLocalKeywords)); + keywordCondition.append(QString("(ifnull(LOCAL_NAME, '') like ? or ifnull(replace(LOCAL_NAME,' ',''), '') like ? or ifnull(NAME_EN, '') like ? or ifnull(replace(NAME_EN,' ',''), '') like ? or ifnull(NAME_ZH, '') like ? or ifnull(replace(NAME_ZH,' ',''), '') like ? or ifnull(FIRST_LETTER_OF_PINYIN, '') like ? or ifnull(replace(FIRST_LETTER_OF_PINYIN,' ',''), '') like ? or ifnull(PINYIN_NAME, '') like ? or ifnull(replace(PINYIN_NAME,' ',''), '') like ? or %0) AND").arg(findWithLocalKeywords)); } } if(!keywordCondition.isEmpty()) { @@ -534,9 +532,9 @@ bool AppInfoTable::query(ApplicationInfoMap &infoMap, const ApplicationPropertie } for(const QString &keyword : keywords) { - int i = 6; + int i = 11; if(keyword.size() < 2) { - i--; + i = i - 2; } for (int bindCount = 0; bindCount < i; bindCount++) { query.bindValue(count, (bindCount - i + 1) ? "%" + keyword + "%" : keyword.toLower());