@Override public BinaryDocValues getBinaryDocValues(String field) throws IOException { if (facetFields.contains(field)) { final OrdinalsReader ordsReader = getOrdinalsReader(field); return new OrdinalMappingBinaryDocValues(ordsReader.getReader(in.getContext())); } else { return in.getBinaryDocValues(field); } }
/** * Create {@code TaxonomyFacetCounts}, which also counts all facet labels. Use this for a * non-default {@link OrdinalsReader}; otherwise use {@link FastTaxonomyFacetCounts}. */ public TaxonomyFacetCounts( OrdinalsReader ordinalsReader, TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc) throws IOException { super(ordinalsReader.getIndexFieldName(), taxoReader, config); this.ordinalsReader = ordinalsReader; count(fc.getMatchingDocs()); }
private final void count(List<MatchingDocs> matchingDocs) throws IOException { IntsRef scratch = new IntsRef(); for (MatchingDocs hits : matchingDocs) { OrdinalsReader.OrdinalsSegmentReader ords = ordinalsReader.getReader(hits.context); DocIdSetIterator docs = hits.bits.iterator(); int doc; while ((doc = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { ords.get(doc, scratch); for (int i = 0; i < scratch.length; i++) { values[scratch.ints[scratch.offset + i]]++; } } } rollup(); }