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 classstatic classUsed forbyCount(CountFacetRecorder, LongValueFacetCutter)result.static classstatic final classstatic classUsed forbyOrdinal()result. -
Method Summary
Modifier and TypeMethodDescriptionbyAggregatedValue(CountFacetRecorder countRecorder, LongAggregationsFacetRecorder longAggregationsFacetRecorder, int aggregationId) ComparableSupplierto sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorderandLongAggregationsFacetRecorder.byCount(CountFacetRecorder recorder) ComparableSupplierto sort ordinals by count (descending) with ord as a tie-break (ascending) using providedCountFacetRecorder.byCount(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter) ComparableSupplierto sort ordinals by count (descending) fromCountFacetRecorderwith tie-break by long value (ascending) fromLongValueFacetCutter.byLongValue(LongValueFacetCutter longValueFacetCutter) ComparableSupplierto sort ordinals by long value fromLongValueFacetCutter(descending).ComparableSupplierto sort by ords (ascending).static <T extends Comparable<T>>
voidsort(int[] ordinals, ComparableSupplier<T> comparableSupplier) Sort array of ordinals.
-
Method Details
-
byOrdinal
ComparableSupplierto sort by ords (ascending). -
byCount
public static ComparableSupplier<ComparableUtils.ByCountComparable> byCount(CountFacetRecorder recorder) ComparableSupplierto 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) ComparableSupplierto sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorderandLongAggregationsFacetRecorder. -
byLongValue
public static ComparableSupplier<ComparableUtils.ByLongValueComparable> byLongValue(LongValueFacetCutter longValueFacetCutter) ComparableSupplierto sort ordinals by long value fromLongValueFacetCutter(descending). -
byCount
public static ComparableSupplier<ComparableUtils.ByCountAndLongValueComparable> byCount(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter) ComparableSupplierto sort ordinals by count (descending) fromCountFacetRecorderwith 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
TopnOrdinalIteratorinstead.- Parameters:
ordinals- array of ordinals to sortcomparableSupplier- defines sort order- Throws:
IOException
-