public class FieldComparator extends ChainableComparator
Note: this comparator imposes orderings that are inconsistent with equals.
Constructor and Description |
---|
FieldComparator(Sorting sorting)
Creates a field comparator using a sort order and having no chained comparator
|
FieldComparator(Sorting sorting,
Comparator<Hit> secondaryComparator)
Creates a field comparator using a sort order with a chained comparator
|
Modifier and Type | Method and Description |
---|---|
int |
compare(Hit first,
Hit second)
Compares hits based on a sorting specification and values
stored in hit fields.0
|
static FieldComparator |
create(Sorting sorting)
Creates a comparator given a sorting, or returns null if the given sorting is null
|
Object |
getField(Hit hit,
String key) |
String |
toString() |
getSecondaryComparator
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public FieldComparator(Sorting sorting)
public FieldComparator(Sorting sorting, Comparator<Hit> secondaryComparator)
public static FieldComparator create(Sorting sorting)
public int compare(Hit first, Hit second)
When one of the hits has the requested property and the other has not, the the hit containing the property precedes the one that does not.
There is no locale based sorting here, as the backend does not do that either.
compare
in interface Comparator<Hit>
compare
in class ChainableComparator
Copyright © 2018. All rights reserved.