From 65ce0a021bf9457075459bc990b1690f95b53318 Mon Sep 17 00:00:00 2001 From: Daniel Naber Date: Sat, 18 Sep 2004 18:21:17 +0000 Subject: [PATCH] order was undefined in case of duplicate sort keys, this could lead to incorrect results (documents appearing twice in the result set, other documents missing) if there were more than 100 matches. PR:31241 git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150523 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/search/FieldSortedHitQueue.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/java/org/apache/lucene/search/FieldSortedHitQueue.java b/src/java/org/apache/lucene/search/FieldSortedHitQueue.java index 9663c847075..dd5dd0bb8a0 100644 --- a/src/java/org/apache/lucene/search/FieldSortedHitQueue.java +++ b/src/java/org/apache/lucene/search/FieldSortedHitQueue.java @@ -95,6 +95,9 @@ extends PriorityQueue { c = (fields[i].reverse) ? comparators[i].compare (docB, docA) : comparators[i].compare (docA, docB); } + // avoid random sort order that could lead to duplicates (bug #31241): + if (c == 0) + return docA.doc > docB.doc; return c > 0; }