Package org.apache.lucene.facet.range

# Class DynamicRangeUtil

java.lang.Object
org.apache.lucene.facet.range.DynamicRangeUtil

public final class DynamicRangeUtil extends Object
Methods to create dynamic ranges for numeric fields.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final record`
  `DynamicRangeUtil.DynamicRangeInfo`
  Holds parameters of a dynamic numeric range.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static List<DynamicRangeUtil.DynamicRangeInfo>`
  `computeDynamicNumericRanges(long[] values, long[] weights, int len, long totalWeight, int topN)`
  Compute dynamic numeric ranges using weights.
  `static List<DynamicRangeUtil.DynamicRangeInfo>`
  `computeDynamicRanges(String weightFieldName, LongValuesSource weightValueSource, LongValuesSource fieldValueSource, FacetsCollector facetsCollector, int topN, ExecutorService exec)`
  Construct dynamic ranges using the specified weight field to generate equi-weight range for the specified numeric bin field

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### computeDynamicRanges

    public static List<DynamicRangeUtil.DynamicRangeInfo> computeDynamicRanges(String weightFieldName, LongValuesSource weightValueSource, LongValuesSource fieldValueSource, FacetsCollector facetsCollector, int topN, ExecutorService exec) throws IOException
    Construct dynamic ranges using the specified weight field to generate equi-weight range for the specified numeric bin field
    Parameters:
      `weightFieldName` - Name of the specified weight field
      `weightValueSource` - Value source of the weight field
      `fieldValueSource` - Value source of the value field
      `facetsCollector` - FacetsCollector
      `topN` - Number of requested ranges
      `exec` - An executor service that is used to do the computation
    Returns:
      A list of DynamicRangeInfo that contains count, relevance, min, max, and centroid for each range
    Throws:
      `IOException`

  - ### computeDynamicNumericRanges

    public static List<DynamicRangeUtil.DynamicRangeInfo> computeDynamicNumericRanges(long[] values, long[] weights, int len, long totalWeight, int topN)
    Compute dynamic numeric ranges using weights.
    Parameters:
      `values` - an array that contains the values of matching documents
      `weights` - an array that contains the weights of matching documents
      `len` - actual length of values and weights
      `totalWeight` - the sum of weight values
      `topN` - the requested top-n parameter
    Returns:
      A list of DynamicRangeInfo that contains count, relevance, min, max, and centroid values for each range. The size of dynamic ranges may not be exactly equal to top-N. top-N is used to compute the equi-weight per bin.