[ 
https://issues.apache.org/jira/browse/LUCENE-7707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15882531#comment-15882531
 ] 

Michael McCandless commented on LUCENE-7707:
--------------------------------------------

Alas, I think we do need to add an explicit boolean to the public API ... this 
test failure repros for me:

{noformat}
 [junit4] Suite: org.apache.lucene.search.TestShardSearching
   [junit4]   2> NOTE: reproduce with: ant test  -Dtestcase=TestShardSearching 
-Dtests.method=testSimple -Dtests.seed=2D10A476239970A9 -Dtests.slow=true 
-Dtests.locale=en-NZ -Dtests.timezone=Navajo -Dtests.asserts=true 
-Dtests.file.encoding=UTF8
   [junit4] FAILURE 0.64s J2 | TestShardSearching.testSimple <<<
   [junit4]    > Throwable #1: java.lang.AssertionError
   [junit4]    >        at 
__randomizedtesting.SeedInfo.seed([2D10A476239970A9:15A38088046AA478]:0)
   [junit4]    >        at 
org.apache.lucene.search.TopDocs.tieBreakLessThan(TopDocs.java:104)
   [junit4]    >        at 
org.apache.lucene.search.TopDocs$MergeSortQueue.lessThan(TopDocs.java:196)
   [junit4]    >        at 
org.apache.lucene.search.TopDocs$MergeSortQueue.lessThan(TopDocs.java:138)
   [junit4]    >        at 
org.apache.lucene.util.PriorityQueue.upHeap(PriorityQueue.java:263)
   [junit4]    >        at 
org.apache.lucene.util.PriorityQueue.add(PriorityQueue.java:140)
   [junit4]    >        at 
org.apache.lucene.search.TopDocs.mergeAux(TopDocs.java:283)
   [junit4]    >        at 
org.apache.lucene.search.TopDocs.merge(TopDocs.java:248)
   [junit4]    >        at 
org.apache.lucene.search.TopDocs.merge(TopDocs.java:232)
   [junit4]    >        at 
org.apache.lucene.search.ShardSearchingTestBase$NodeState$ShardIndexSearcher.search(ShardSearchingTestBase.java:440)
   [junit4]    >        at 
org.apache.lucene.search.TestShardSearching.assertSame(TestShardSearching.java:313)
   [junit4]    >        at 
org.apache.lucene.search.TestShardSearching.testSimple(TestShardSearching.java:236)
   [junit4]    >        at java.lang.Thread.run(Thread.java:745)
{noformat}

It happens because IndexSearcher will sometimes (when using an executor) set 
the shardIndex of the TopDocs it returns to the caller, but it should not (so 
that the caller can then later do their own merging).  Likewise, grouping, 
drill sideways ...

I'll work on a patch to make it explicit...

> Only assign ScoreDoc#shardIndex if it was already assigned to non default 
> (-1) value
> ------------------------------------------------------------------------------------
>
>                 Key: LUCENE-7707
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7707
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Simon Willnauer
>            Assignee: Simon Willnauer
>             Fix For: master (7.0), 6.5.0
>
>         Attachments: LUCENE-7707.patch, LUCENE-7707.patch, LUCENE-7707.patch, 
> LUCENE-7707.patch, LUCENE-7707.patch, LUCENE-7707.patch
>
>
> When you use TopDocs.merge today it always overrides the ScoreDoc#shardIndex 
> value. The assumption that is made here is that all shard results are merges 
> at once which is not necessarily the case. If for instance incremental merge 
> phases are applied the shard index doesn't correspond to the index in the 
> outer TopDocs array. To make this a backwards compatible but yet 
> non-controversial change we could change the internals of TopDocs#merge to 
> only assign this value unless it's not been assigned before to a non-default 
> (-1) value to allow multiple or sparse top docs merging.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to