Example usage for org.apache.lucene.facet.taxonomy ParallelTaxonomyArrays children

List of usage examples for org.apache.lucene.facet.taxonomy ParallelTaxonomyArrays children

Introduction

In this page you can find the example usage for org.apache.lucene.facet.taxonomy ParallelTaxonomyArrays children.

Prototype

public abstract int[] children();

Source Link

Document

Returns the children array, where children[i] denotes a child of category ordinal i .

Usage

From source file:org.exist.indexing.lucene.QueryFacetCollector.java

License:Open Source License

private List<FacetResult> accumulate() throws IOException {

    // aggregate facets per category list (usually only one category list)
    FacetsAggregator aggregator = getAggregator();
    for (CategoryListParams clp : getCategoryLists()) {
        for (MatchingDocs md : matchingDocs) {
            aggregator.aggregate(md, clp, facetArrays);
        }//from  w w w .  j a v a 2s. c  o m
    }

    ParallelTaxonomyArrays arrays = taxonomyReader.getParallelTaxonomyArrays();

    // compute top-K
    final int[] children = arrays.children();
    final int[] siblings = arrays.siblings();
    List<FacetResult> res = new ArrayList<>();
    for (FacetRequest fr : searchParams.facetRequests) {
        int rootOrd = taxonomyReader.getOrdinal(fr.categoryPath);
        // category does not exist
        if (rootOrd == TaxonomyReader.INVALID_ORDINAL) {
            // Add empty FacetResult
            res.add(emptyResult(rootOrd, fr));
            continue;
        }
        CategoryListParams clp = searchParams.indexingParams.getCategoryListParams(fr.categoryPath);
        // someone might ask to aggregate ROOT category
        if (fr.categoryPath.length > 0) {
            OrdinalPolicy ordinalPolicy = clp.getOrdinalPolicy(fr.categoryPath.components[0]);
            if (ordinalPolicy == OrdinalPolicy.NO_PARENTS) {
                // rollup values
                aggregator.rollupValues(fr, rootOrd, children, siblings, facetArrays);
            }
        }

        FacetResultsHandler frh = createFacetResultsHandler(fr);
        res.add(frh.compute());
    }
    return res;
}