Class SortableEntry

java.lang.Object
io.fluxcapacitor.common.api.search.SortableEntry
All Implemented Interfaces:
Comparable<SortableEntry>

public class SortableEntry extends Object implements Comparable<SortableEntry>
Represents a sortable entry in a Document for use in search operations.

SortableEntry values are primarily used to support efficient sorting and range filtering in the document store (e.g., numeric or timestamp-based queries). Each entry consists of a name (field path) and a pre-normalized, lexicographically sortable value as a String.

Values are formatted using a normalization strategy depending on their type:

Example Use Cases

  • Sorting search results by timestamp or numeric score
  • Enabling fast BetweenConstraint evaluation
  • Filtering or grouping based on normalized values
See Also:
  • Field Details

    • comparator

      public static final Comparator<SortableEntry> comparator
      Comparator used to lexicographically compare entries based on name and value.
  • Constructor Details

    • SortableEntry

      public SortableEntry(String name, Object value)
      Constructs a new SortableEntry by formatting the given object into a normalized, sortable string.
      Parameters:
      name - the field name or path
      value - the raw object value (e.g., Number, Instant, or String)
  • Method Details

    • formatSortable

      public static String formatSortable(Object value)
      Formats the given object into a sortable string depending on its type.
      • For Numbers: Encoded as zero-padded base-10
      • For Instants: Formatted as ISO-8601 string
      • Other objects: Normalized string representation
    • compareTo

      public int compareTo(@NotNull SortableEntry o)
      Specified by:
      compareTo in interface Comparable<SortableEntry>
    • toSortableString

      public static String toSortableString(Number number)
      Converts a Number to a lexicographically sortable zero-padded string.