Search in sources :

Example 1 with OrdRange

use of org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState.OrdRange in project lucene-solr by apache.

the class ConcurrentSortedSetDocValuesFacetCounts method getAllDims.

@Override
public List<FacetResult> getAllDims(int topN) throws IOException {
    List<FacetResult> results = new ArrayList<>();
    for (Map.Entry<String, OrdRange> ent : state.getPrefixToOrdRange().entrySet()) {
        FacetResult fr = getDim(ent.getKey(), ent.getValue(), topN);
        if (fr != null) {
            results.add(fr);
        }
    }
    // Sort by highest count:
    Collections.sort(results, new Comparator<FacetResult>() {

        @Override
        public int compare(FacetResult a, FacetResult b) {
            if (a.value.intValue() > b.value.intValue()) {
                return -1;
            } else if (b.value.intValue() > a.value.intValue()) {
                return 1;
            } else {
                return a.dim.compareTo(b.dim);
            }
        }
    });
    return results;
}
Also used : OrdRange(org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState.OrdRange) ArrayList(java.util.ArrayList) FacetResult(org.apache.lucene.facet.FacetResult) Map(java.util.Map)

Example 2 with OrdRange

use of org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState.OrdRange in project lucene-solr by apache.

the class SortedSetDocValuesFacetCounts method getAllDims.

@Override
public List<FacetResult> getAllDims(int topN) throws IOException {
    List<FacetResult> results = new ArrayList<>();
    for (Map.Entry<String, OrdRange> ent : state.getPrefixToOrdRange().entrySet()) {
        FacetResult fr = getDim(ent.getKey(), ent.getValue(), topN);
        if (fr != null) {
            results.add(fr);
        }
    }
    // Sort by highest count:
    Collections.sort(results, new Comparator<FacetResult>() {

        @Override
        public int compare(FacetResult a, FacetResult b) {
            if (a.value.intValue() > b.value.intValue()) {
                return -1;
            } else if (b.value.intValue() > a.value.intValue()) {
                return 1;
            } else {
                return a.dim.compareTo(b.dim);
            }
        }
    });
    return results;
}
Also used : OrdRange(org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState.OrdRange) ArrayList(java.util.ArrayList) FacetResult(org.apache.lucene.facet.FacetResult) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 FacetResult (org.apache.lucene.facet.FacetResult)2 OrdRange (org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState.OrdRange)2