jpountz commented on a change in pull request #734: LUCENE-8857: Introduce Custom Tiebreakers in TopDocs#merge URL: https://github.com/apache/lucene-solr/pull/734#discussion_r297563914
########## File path: lucene/core/src/java/org/apache/lucene/search/TopDocs.java ########## @@ -276,11 +308,12 @@ private static TopDocs mergeAux(Sort sort, int start, int size, TopDocs[] shardH assert queue.size() > 0; ShardRef ref = queue.top(); final ScoreDoc hit = shardHits[ref.shardIndex].scoreDocs[ref.hitIndex++]; - if (setShardIndex) { - // caller asked us to record shardIndex (index of the TopDocs array) this hit is coming from: - hit.shardIndex = ref.shardIndex; - } else if (hit.shardIndex == -1) { - throw new IllegalArgumentException("setShardIndex is false but TopDocs[" + ref.shardIndex + "].scoreDocs[" + (ref.hitIndex-1) + "] is not set"); + + //Irrespective of whether we use shard indices for tie breaking or not, we check for consistent + // order in shard indices to defend against potential bugs + if ((unsetShardIndex && hit.shardIndex != -1) || + (unsetShardIndex == false && hit.shardIndex == -1)) { Review comment: we could combine both into `unsetShardIndex != (hit.shardIndex == -1)` ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org