@@ -140,7 +140,7 @@ public final void executeNextPhase(SearchPhase currentPhase, SearchPhase nextPha
140
140
} else {
141
141
Boolean allowPartialResults = request .allowPartialSearchResults ();
142
142
assert allowPartialResults != null : "SearchRequest missing setting for allowPartialSearchResults" ;
143
- if (allowPartialResults == false && shardFailures .get () != null ) {
143
+ if (allowPartialResults == false && successfulOps .get () != getNumShards () ) {
144
144
// check if there are actual failures in the atomic array since
145
145
// successful retries can reset the failures to null
146
146
ShardOperationFailedException [] shardSearchFailures = buildShardFailures ();
@@ -154,18 +154,17 @@ public final void executeNextPhase(SearchPhase currentPhase, SearchPhase nextPha
154
154
}
155
155
onPhaseFailure (currentPhase , "Partial shards failure" , null );
156
156
return ;
157
+ } else {
158
+ int discrepancy = getNumShards () - successfulOps .get ();
159
+ assert discrepancy > 0 : "discrepancy: " + discrepancy ;
160
+ if (logger .isDebugEnabled ()) {
161
+ logger .debug ("Partial shards failure (unavailable: {}, successful: {}, skipped: {}, num-shards: {}, phase: {})" ,
162
+ discrepancy , successfulOps .get (), skippedOps .get (), getNumShards (), currentPhase .getName ());
163
+ }
164
+ onPhaseFailure (currentPhase , "Partial shards failure (" + discrepancy + " shards unavailable)" , null );
165
+ return ;
157
166
}
158
167
}
159
- if (allowPartialResults == false && successfulOps .get () != getNumShards ()) {
160
- int discrepancy = getNumShards () - successfulOps .get ();
161
- assert discrepancy > 0 : "discrepancy: " + discrepancy ;
162
- if (logger .isDebugEnabled ()) {
163
- logger .debug ("Partial shards failure (unavailable: {}, successful: {}, skipped: {}, num-shards: {}, phase: {})" ,
164
- discrepancy , successfulOps .get (), skippedOps .get (), getNumShards (), currentPhase .getName ());
165
- }
166
- onPhaseFailure (currentPhase , "Partial shards failure (" + discrepancy + " shards unavailable)" , null );
167
- return ;
168
- }
169
168
if (logger .isTraceEnabled ()) {
170
169
final String resultsFrom = results .getSuccessfulResults ()
171
170
.map (r -> r .getSearchShardTarget ().toString ()).collect (Collectors .joining ("," ));
0 commit comments