Raise an exception on an array of values being sent as the factor for a field_value_factor query
closes #7408
This commit is contained in:
parent
4732ef3484
commit
2436552840
|
@ -70,6 +70,8 @@ public class FieldValueFactorFunctionParser implements ScoreFunctionParser {
|
|||
} else {
|
||||
throw new QueryParsingException(parseContext.index(), NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if("factor".equals(currentFieldName) && (token == XContentParser.Token.START_ARRAY || token == XContentParser.Token.START_OBJECT)) {
|
||||
throw new QueryParsingException(parseContext.index(), "[" + NAMES[0] + "] field 'factor' does not support lists or objects");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,5 +100,34 @@ public class FunctionScoreFieldValueTests extends ElasticsearchIntegrationTest {
|
|||
// This is fine, the query will throw an exception if executed
|
||||
// locally, instead of just having failures
|
||||
}
|
||||
|
||||
// don't permit an array of factors
|
||||
try {
|
||||
String querySource = "{" +
|
||||
"\"query\": {" +
|
||||
" \"function_score\": {" +
|
||||
" \"query\": {" +
|
||||
" \"match\": {\"name\": \"foo\"}" +
|
||||
" }," +
|
||||
" \"functions\": [" +
|
||||
" {" +
|
||||
" \"field_value_factor\": {" +
|
||||
" \"field\": \"test\"," +
|
||||
" \"factor\": [1.2,2]" +
|
||||
" }" +
|
||||
" }" +
|
||||
" ]" +
|
||||
" }" +
|
||||
" }" +
|
||||
"}";
|
||||
response = client().prepareSearch("test")
|
||||
.setSource(querySource)
|
||||
.get();
|
||||
assertFailures(response);
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
// This is fine, the query will throw an exception if executed
|
||||
// locally, instead of just having failures
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue