file_systems/QueryParser: Don't let the equation score be 0 if there's an index.

Without this, a query term that does have an index but for which
the pattern starts with a wildcard (e.g. "*term*") is treated as having
a score of 0. That means that it is then dependent on the query order
as to whether or not the equation will run at all, since if all the terms
have a score of 0 but one has an index, placing that term first
will make the query run while any other would not.

Fixes #18672.
This commit is contained in:
Augustin Cavalier
2024-06-26 18:20:50 -04:00
parent 88911fe61c
commit 44e9aa9f33
+7 -2
View File
@@ -768,9 +768,14 @@ Equation<QueryPolicy>::CalculateScore(Index &index)
}
// if we have a pattern, how much does it help our search?
if (fIsPattern)
if (fIsPattern) {
fScore = getFirstPatternSymbol(fString) << 3;
else {
// Even if the first pattern symbol is at position 0,
// there's still an index, so don't let our score revert to zero.
if (fScore == 0)
fScore = 1;
} else {
// Score by operator
if (Term<QueryPolicy>::fOp == OP_EQUAL) {
// higher than pattern="255 chars+*"