SearchContext searchContext = SearchContext.current();
FieldMapper mapper = searchContext.mapperService().smartNameFieldMapper(field);
if (mapper == null) {
throw new ElasticsearchException("Unable to find a field mapper for field [" + field + "]");
}
return new FieldValueFactorFunction(field, boostFactor, modifier,
(IndexNumericFieldData)searchContext.fieldData().getForField(mapper));
}