Shiming Li created SOLR-18136:
---------------------------------
Summary: ArrayStoreException in MultiThreadedSearcher when
combining rerank with sort and parallel segment search
Key: SOLR-18136
URL: https://issues.apache.org/jira/browse/SOLR-18136
Project: Solr
Issue Type: Bug
Affects Versions: 9.10.1, main(11.0)
Reporter: Shiming Li
*Summary*
When multi-threaded segment-parallel search is enabled
(`indexSearcherExecutorThreads > 0` and `multiThreaded=true`)
and a query uses both *{*}reranking{*}* (via `RankQuery` / `ReRankCollector`)
and a *{*}sort{*}*, an `ArrayStoreException` is
thrown during the merge phase if some segments have matching documents and
others do not.
*Error Message*
{code:java}
java.lang.ArrayStoreException: arraycopy: element type mismatch: can not cast
one of the elements
of org.apache.lucene.search.TopDocs[] to the type of the destination array,
org.apache.lucene.search.TopFieldDocs
{code}
*Root Cause*
In `MultiThreadedSearcher.TopDocsCM.reduce()`, the code decides how to merge
`TopDocs` from
different slices based solely on the type of `topDocs[0]`:
{code:java}
if (topDocs[0] instanceof TopFieldDocs) {
TopFieldDocs[] topFieldDocs = Arrays.copyOf(topDocs, topDocs.length,
TopFieldDocs[].class);
...
}
{code}
When a ReRankCollector is used with a sort:
Empty-result segments return TopFieldDocs (from the underlying
TopFieldCollector)
Non-empty segments return plain TopDocs (after ReRankCollector.toRescoredDocs()
wraps
results with new TopDocs(...), discarding the TopFieldDocs subtype)
When Lucene splits segments into multiple slices for parallel search, different
slices may produce
different TopDocs subtypes. If an empty-result slice happens to be first in the
array,
topDocs[0] is TopFieldDocs, and Arrays.copyOf(..., TopFieldDocs[].class) fails
because the
array also contains plain TopDocs elements.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]