Core: Protects against: 'from + size > scoreDocs.length' in case only single shard response
This commit is contained in:
parent
e8995ecaa7
commit
f51a09d8f7
|
@ -172,15 +172,19 @@ public class SearchPhaseController extends AbstractComponent {
|
|||
}
|
||||
}
|
||||
if (canOptimize) {
|
||||
ScoreDoc[] scoreDocs = result.topDocs().scoreDocs;
|
||||
if (scoreDocs.length == 0) {
|
||||
return EMPTY_DOCS;
|
||||
}
|
||||
int resultDocsSize = scoreDocs.length < result.size() ? scoreDocs.length : result.size();
|
||||
int offset = result.from();
|
||||
if (scrollSort) {
|
||||
offset = 0;
|
||||
}
|
||||
ScoreDoc[] scoreDocs = result.topDocs().scoreDocs;
|
||||
if (scoreDocs.length == 0 || scoreDocs.length < offset) {
|
||||
return EMPTY_DOCS;
|
||||
}
|
||||
|
||||
int resultDocsSize = result.size();
|
||||
if ((scoreDocs.length - offset) < resultDocsSize) {
|
||||
resultDocsSize = scoreDocs.length - offset;
|
||||
}
|
||||
ScoreDoc[] docs = new ScoreDoc[resultDocsSize];
|
||||
for (int i = 0; i < resultDocsSize; i++) {
|
||||
ScoreDoc scoreDoc = scoreDocs[offset + i];
|
||||
|
|
Loading…
Reference in New Issue