From 44e9aa9f33362610664d209135e23215accc0a0d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 26 Jun 2024 18:20:50 -0400 Subject: [PATCH] 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. --- headers/private/file_systems/QueryParser.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/headers/private/file_systems/QueryParser.h b/headers/private/file_systems/QueryParser.h index bcc6a29616..7c5fcc70f6 100644 --- a/headers/private/file_systems/QueryParser.h +++ b/headers/private/file_systems/QueryParser.h @@ -768,9 +768,14 @@ Equation::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::fOp == OP_EQUAL) { // higher than pattern="255 chars+*"