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

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

Introduction

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

Prototype

public abstract int[] siblings();

Source Link

Document

Returns the siblings array, where siblings[i] denotes the sibling 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. java  2s  .  co  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;
}