Class ComparableUtils
java.lang.Object
org.apache.lucene.sandbox.facet.utils.ComparableUtils
Collection of static methods to provide most common comparables for sandbox faceting. You can
also use it as an example for creating your own
ComparableSupplier
to enable custom
facets top-n and sorting.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
Used forbyCount(CountFacetRecorder, LongValueFacetCutter)
result.static class
static final class
static class
Used forbyOrdinal()
result. -
Method Summary
Modifier and TypeMethodDescriptionbyAggregatedValue
(CountFacetRecorder countRecorder, LongAggregationsFacetRecorder longAggregationsFacetRecorder, int aggregationId) ComparableSupplier
to sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorder
andLongAggregationsFacetRecorder
.byCount
(CountFacetRecorder recorder) ComparableSupplier
to sort ordinals by count (descending) with ord as a tie-break (ascending) using providedCountFacetRecorder
.byCount
(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter) ComparableSupplier
to sort ordinals by count (descending) fromCountFacetRecorder
with tie-break by long value (ascending) fromLongValueFacetCutter
.byLongValue
(LongValueFacetCutter longValueFacetCutter) ComparableSupplier
to sort ordinals by long value fromLongValueFacetCutter
(descending).ComparableSupplier
to sort by ords (ascending).static <T extends Comparable<T>>
voidsort
(int[] ordinals, ComparableSupplier<T> comparableSupplier) Sort array of ordinals.
-
Method Details
-
byOrdinal
ComparableSupplier
to sort by ords (ascending). -
byCount
public static ComparableSupplier<ComparableUtils.ByCountComparable> byCount(CountFacetRecorder recorder) ComparableSupplier
to sort ordinals by count (descending) with ord as a tie-break (ascending) using providedCountFacetRecorder
. -
byAggregatedValue
public static ComparableSupplier<ComparableUtils.ByAggregatedValueComparable> byAggregatedValue(CountFacetRecorder countRecorder, LongAggregationsFacetRecorder longAggregationsFacetRecorder, int aggregationId) ComparableSupplier
to sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorder
andLongAggregationsFacetRecorder
. -
byLongValue
public static ComparableSupplier<ComparableUtils.ByLongValueComparable> byLongValue(LongValueFacetCutter longValueFacetCutter) ComparableSupplier
to sort ordinals by long value fromLongValueFacetCutter
(descending). -
byCount
public static ComparableSupplier<ComparableUtils.ByCountAndLongValueComparable> byCount(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter) ComparableSupplier
to sort ordinals by count (descending) fromCountFacetRecorder
with tie-break by long value (ascending) fromLongValueFacetCutter
. -
sort
public static <T extends Comparable<T>> void sort(int[] ordinals, ComparableSupplier<T> comparableSupplier) throws IOException Sort array of ordinals.To get top-n ordinals use
TopnOrdinalIterator
instead.- Parameters:
ordinals
- array of ordinals to sortcomparableSupplier
- defines sort order- Throws:
IOException
-