If no mapping can be found for value field, throw a proper exception.

This commit is contained in:
Martijn van Groningen 2013-08-01 14:09:41 +02:00
parent 13845e47d6
commit 31fd7764e7
1 changed files with 3 additions and 1 deletions

View File

@ -121,7 +121,9 @@ public class TermsStatsFacetParser extends AbstractComponent implements FacetPar
SearchScript valueScript = null;
if (valueField != null) {
FieldMapper fieldMapper = context.smartNameFieldMapper(valueField);
if (!(fieldMapper instanceof NumberFieldMapper)) {
if (fieldMapper == null) {
throw new FacetPhaseExecutionException(facetName, "failed to find mapping for " + valueField);
} else if (!(fieldMapper instanceof NumberFieldMapper)) {
throw new FacetPhaseExecutionException(facetName, "value_field [" + valueField + "] isn't a number field, but a " + fieldMapper.fieldDataType().getType());
}
valueIndexFieldData = context.fieldData().getForField(fieldMapper);