Search: When all shards fail on second / third phase, make sure to return a response with proper shard failures, closes #1033.
This commit is contained in:
parent
b7d492af4b
commit
bbd73d5afa
|
@ -20,7 +20,11 @@
|
|||
package org.elasticsearch.search.controller;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.FieldDoc;
|
||||
import org.apache.lucene.search.ScoreDoc;
|
||||
import org.apache.lucene.search.ShardFieldDocSortedHitQueue;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TopFieldDocs;
|
||||
import org.apache.lucene.util.PriorityQueue;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.collect.Iterables;
|
||||
|
@ -256,7 +260,13 @@ public class SearchPhaseController extends AbstractComponent {
|
|||
|
||||
boolean sorted = false;
|
||||
int sortScoreIndex = -1;
|
||||
QuerySearchResult querySearchResult = Iterables.get(queryResults.values(), 0).queryResult();
|
||||
QuerySearchResult querySearchResult;
|
||||
try {
|
||||
querySearchResult = Iterables.get(queryResults.values(), 0).queryResult();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// no results, return an empty response
|
||||
return InternalSearchResponse.EMPTY;
|
||||
}
|
||||
|
||||
if (querySearchResult.topDocs() instanceof TopFieldDocs) {
|
||||
sorted = true;
|
||||
|
|
|
@ -43,6 +43,8 @@ public class InternalSearchResponse implements Streamable, ToXContent {
|
|||
|
||||
private boolean timedOut;
|
||||
|
||||
public static final InternalSearchResponse EMPTY = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[0], 0, 0), null, false);
|
||||
|
||||
private InternalSearchResponse() {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue