feat(app-search):应用搜索支持去掉空格匹配
This commit is contained in:
parent
b9b41c7ccd
commit
1aa1a39b58
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue