Made all the queries support `score_mode` parameter name in addition to the existing parameter name for score mode.

Closes #3026
This commit is contained in:
Martijn van Groningen 2013-05-13 10:29:34 +02:00
parent bacf969dd3
commit 6eaad25621
4 changed files with 16 additions and 0 deletions

View File

@ -89,6 +89,11 @@ public class HasChildQueryParser implements QueryParser {
if (!"none".equals(scoreTypeValue)) {
scoreType = ScoreType.fromString(scoreTypeValue);
}
} else if ("score_mode".equals(currentFieldName) || "scoreMode".equals(currentFieldName)) {
String scoreModeValue = parser.text();
if (!"none".equals(scoreModeValue)) {
scoreType = ScoreType.fromString(scoreModeValue);
}
} else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue();
} else {

View File

@ -92,6 +92,13 @@ public class HasParentQueryParser implements QueryParser {
} else if ("none".equals(scoreTypeValue)) {
score = false;
}
} else if ("score_mode".equals(currentFieldName) || "scoreMode".equals(currentFieldName)) {
String scoreModeValue = parser.text();
if ("score".equals(scoreModeValue)) {
score = true;
} else if ("none".equals(scoreModeValue)) {
score = false;
}
} else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue();
} else {

View File

@ -86,6 +86,8 @@ public class TopChildrenQueryParser implements QueryParser {
throw new QueryParsingException(parseContext.index(), "the [_scope] support in [top_children] query has been removed, use a filter as a facet_filter in the relevant global facet");
} else if ("score".equals(currentFieldName)) {
scoreType = ScoreType.fromString(parser.text());
} else if ("score_mode".equals(currentFieldName) || "scoreMode".equals(currentFieldName)) {
scoreType = ScoreType.fromString(parser.text());
} else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue();
} else if ("factor".equals(currentFieldName)) {

View File

@ -48,6 +48,8 @@ public enum ScoreType {
return AVG;
} else if ("sum".equals(type)) {
return SUM;
} else if ("total".equals(type)) { // This name is consistent with: ScoreMode.Total
return SUM;
}
throw new ElasticSearchIllegalArgumentException("No score type for child query [" + type + "] found");
}