/** {@inheritDoc} */ public void setNextReader(LeafReaderContext ctx) throws IOException { if (valueSource == null) { // first time we've collected local values, get the right ValueSource valueSource = (null == ft) ? statsField.getValueSource() : ft.getValueSource(sf, null); vsContext = ValueSource.newContext(statsField.getSearcher()); } values = valueSource.getValues(vsContext, ctx); }