Skip to content

Commit

Permalink
Fail a DFS_QUERY_THEN_FETCH request if all shards failed the QUERY ph…
Browse files Browse the repository at this point in the history
…ase.

Today, if some shards pass the DFS phase but all of them fail the QUERY phase,
the response will only consist of failed shards. We should throw an exception
instead in order to be consistent with the QUERY_THEN_FETCH type.
  • Loading branch information
jpountz committed Apr 24, 2014
1 parent cb8139a commit d8880f2
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -22,10 +22,7 @@
import com.carrotsearch.hppc.IntArrayList;
import org.apache.lucene.search.ScoreDoc;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.search.ReduceSearchPhaseException;
import org.elasticsearch.action.search.SearchOperationThreading;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.*;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.inject.Inject;
Expand Down Expand Up @@ -170,7 +167,11 @@ void onQueryFailure(Throwable t, QuerySearchRequest querySearchRequest, int shar
this.addShardFailure(shardIndex, dfsResult.shardTarget(), t);
successfulOps.decrementAndGet();
if (counter.decrementAndGet() == 0) {
executeFetchPhase();
if (successfulOps.get() == 0) {
listener.onFailure(new SearchPhaseExecutionException("query", "all shards failed", buildShardFailures()));
} else {
executeFetchPhase();
}
}
}

Expand Down

0 comments on commit d8880f2

Please sign in to comment.