From 801c025d7b8421f722c2f969acaf5502ea16a465 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 12 Jul 2025 15:48:14 -0400 Subject: [PATCH] file_systems/QueryParser: Invoke ConvertValue in CalculateScore. We need fSize to be set for operator scoring. Also, use operator scoring for GREATER_THAN and GREATER_THAN_OR_EQUAL. Fixes a KDL reported in #19677. --- headers/private/file_systems/QueryParser.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/headers/private/file_systems/QueryParser.h b/headers/private/file_systems/QueryParser.h index e6184967a0..e942e15409 100644 --- a/headers/private/file_systems/QueryParser.h +++ b/headers/private/file_systems/QueryParser.h @@ -373,6 +373,7 @@ Equation::Equation(const char** expr) fAttribute(NULL), fString(NULL), fType(0), + fSize(0), fIsPattern(false), fScore(INT32_MAX) { @@ -766,7 +767,13 @@ Equation::CalculateScore(Index &index) // And the code could also need some real world testing :-) // do we have to operate on a "foreign" index? - if (QueryPolicy::IndexSetTo(index, fAttribute) < B_OK) { + if (QueryPolicy::IndexSetTo(index, fAttribute) != B_OK) { + fScore = INT32_MAX; + return; + } + + if (ConvertValue(QueryPolicy::IndexGetType(index), + QueryPolicy::IndexGetKeySize(index)) != B_OK) { fScore = INT32_MAX; return; } @@ -787,7 +794,9 @@ Equation::CalculateScore(Index &index) fScore /= divisor; } else { // Score by operator - if (Term::fOp == OP_EQUAL) { + if (Term::fOp == OP_EQUAL + || Term::fOp == OP_GREATER_THAN + || Term::fOp == OP_GREATER_THAN_OR_EQUAL) { // higher than most patterns fScore /= (fSize > 8) ? 8 : fSize; } else {