diff --git a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java index 91c015f6b85..f145c313e9d 100644 --- a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java +++ b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java @@ -69,7 +69,7 @@ public final class FragmentBuilderHelper { public int compare(SubInfo o1, SubInfo o2) { int startOffset = o1.getTermsOffsets().get(0).getStartOffset(); int startOffset2 = o2.getTermsOffsets().get(0).getStartOffset(); - return Integer.compare(startOffset, startOffset2); + return FragmentBuilderHelper.compare(startOffset, startOffset2); } }); return new WeightedFragInfo(Math.min(fragInfo.getSubInfos().get(0).getTermsOffsets().get(0).getStartOffset(), @@ -78,6 +78,10 @@ public final class FragmentBuilderHelper { return fragInfo; } } + + private static int compare(int x, int y) { + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } private static boolean containsBrokenAnalysis(Analyzer analyzer) { // TODO maybe we need a getter on Namedanalyzer that tells if this uses broken Analysis