Commit 2e01a251 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

Revert "Use subseq matching for service runner"

This reverts commit 9f2abd0a.

Scores are adjusted by launch count, so pulling more matches into a
context increases the chance of one of them outscoring the other even
though they have nothing to do with it.

Notable example:
Flatpaks have extremely long Exec lines meaning they match just about
any subsequence match once we've reached 3 query characters.
So then a konversation flatpak matches the query 'tel' same as telegram.
Now if you are more into IRC than into telegram you may have a higher
launch count applying to konversation and all of a sudden the
objectively better match for the query is no longer at the top.

In lieu of a way to prevent this from happening with krunner 5.78 we'll
need to undo the subsequencing for now.

For future reference: Kai and I believe Exec and Comment shouldn't be
subsequence matched at all because Exec just makes no sense to begin
with and Comment can be so very long so it will suffer the same problem
as outlined. The more text there is the higher the chance of it matching
the subsequence simply having having all the characters appear anywhere.

Further future reference: subseq needs a test case added to the unit
test if it makes a return!

BUG: 431609
BUG: 432339
CCBUG: 262837
FIXED-IN: 5.21.0


(cherry picked from commit dc65943e)
parent 354fcbd2
......@@ -155,12 +155,12 @@ private:
// they exist to prevent a tree evaluation error if they are not defined.
for (const QStringRef &str : strList) {
keywordTemplate += QStringLiteral(" and '%1' ~subin Keywords").arg(str.toString());
genericNameTemplate += QStringLiteral(" and '%1' ~subseq GenericName").arg(str.toString());
nameTemplate += QStringLiteral(" and '%1' ~subseq Name").arg(str.toString());
commentTemplate += QStringLiteral(" and '%1' ~subseq Comment").arg(str.toString());
genericNameTemplate += QStringLiteral(" and '%1' ~~ GenericName").arg(str.toString());
nameTemplate += QStringLiteral(" and '%1' ~~ Name").arg(str.toString());
commentTemplate += QStringLiteral(" and '%1' ~~ Comment").arg(str.toString());
}
QString finalQuery = QStringLiteral("exist Exec and ( (%1) or (%2) or (%3) or ('%4' ~subseq Exec) or (%5) )")
QString finalQuery = QStringLiteral("exist Exec and ( (%1) or (%2) or (%3) or ('%4' ~~ Exec) or (%5) )")
.arg(keywordTemplate, genericNameTemplate, nameTemplate, strList[0].toString(), commentTemplate);
qCDebug(RUNNER_SERVICES) << "Final query : " << finalQuery;
......@@ -224,7 +224,7 @@ private:
// If the term length is < 3, no real point searching the Keywords and GenericName
if (weightedTermLength < 3) {
query = QStringLiteral("exist Exec and ( (exist Name and '%1' ~subseq Name) or ('%1' ~subseq Exec) )").arg(term);
query = QStringLiteral("exist Exec and ( (exist Name and '%1' ~~ Name) or ('%1' ~~ Exec) )").arg(term);
} else {
// Match using subsequences (Bug: 262837)
query = generateQuery(queryList);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment