/** Create {@code LongValueFacetCounts}, using the provided * {@link LongValuesSource}. * random access (implement {@link org.apache.lucene.search.DocIdSet#bits}). */ public LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits, boolean multiValued) throws IOException { this.field = field; if (valueSource == null) { if (multiValued) { countMultiValued(field, hits.getMatchingDocs()); } else { count(field, hits.getMatchingDocs()); } } else { // value source is always single valued if (multiValued) { throw new IllegalArgumentException("can only compute multi-valued facets directly from doc values (when valueSource is null)"); } count(valueSource, hits.getMatchingDocs()); } }