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.
This commit is contained in:
@@ -373,6 +373,7 @@ Equation<QueryPolicy>::Equation(const char** expr)
|
|||||||
fAttribute(NULL),
|
fAttribute(NULL),
|
||||||
fString(NULL),
|
fString(NULL),
|
||||||
fType(0),
|
fType(0),
|
||||||
|
fSize(0),
|
||||||
fIsPattern(false),
|
fIsPattern(false),
|
||||||
fScore(INT32_MAX)
|
fScore(INT32_MAX)
|
||||||
{
|
{
|
||||||
@@ -766,7 +767,13 @@ Equation<QueryPolicy>::CalculateScore(Index &index)
|
|||||||
// And the code could also need some real world testing :-)
|
// And the code could also need some real world testing :-)
|
||||||
|
|
||||||
// do we have to operate on a "foreign" index?
|
// 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;
|
fScore = INT32_MAX;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -787,7 +794,9 @@ Equation<QueryPolicy>::CalculateScore(Index &index)
|
|||||||
fScore /= divisor;
|
fScore /= divisor;
|
||||||
} else {
|
} else {
|
||||||
// Score by operator
|
// Score by operator
|
||||||
if (Term<QueryPolicy>::fOp == OP_EQUAL) {
|
if (Term<QueryPolicy>::fOp == OP_EQUAL
|
||||||
|
|| Term<QueryPolicy>::fOp == OP_GREATER_THAN
|
||||||
|
|| Term<QueryPolicy>::fOp == OP_GREATER_THAN_OR_EQUAL) {
|
||||||
// higher than most patterns
|
// higher than most patterns
|
||||||
fScore /= (fSize > 8) ? 8 : fSize;
|
fScore /= (fSize > 8) ? 8 : fSize;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user