Skip to content

Commit b48d64d

Browse files
save condition
1 parent a16508f commit b48d64d

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ public SearchPhaseController.ReducedQueryPhase reduce() throws Exception {
220220
consumePartialMergeResult(batchedResult.v2(), topDocsList, aggsList);
221221
}
222222
for (QuerySearchResult result : buffer) {
223-
if (result.isReduced()) {
224-
continue;
225-
}
226223
topDocsStats.add(result.topDocs(), result.searchTimedOut(), result.terminatedEarly());
227224
if (topDocsList != null) {
228225
TopDocsAndMaxScore topDocs = result.consumeTopDocs();
@@ -350,7 +347,7 @@ private MergeResult partialReduce(
350347
} finally {
351348
releaseAggs(toConsume);
352349
for (QuerySearchResult querySearchResult : toConsume) {
353-
querySearchResult.setReduced();
350+
querySearchResult.markAsPartiallyReduced();
354351
}
355352
}
356353
if (lastMerge != null) {
@@ -413,8 +410,8 @@ private void consume(QuerySearchResult result, Runnable next) {
413410
if (hasFailure()) {
414411
result.consumeAll();
415412
next.run();
416-
} else if (result.isNull() || result.isReduced()) {
417-
if (result.isReduced()) {
413+
} else if (result.isNull() || result.isPartiallyReduced()) {
414+
if (result.isPartiallyReduced()) {
418415
if (result.hasConsumedTopDocs() == false) {
419416
result.consumeTopDocs();
420417
}

server/src/main/java/org/elasticsearch/action/search/SearchPhase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ protected static void releaseIrrelevantSearchContext(SearchPhaseResult searchPha
9191
? searchPhaseResult.queryResult()
9292
: searchPhaseResult.rankFeatureResult();
9393
if (phaseResult != null
94-
&& (phaseResult.hasSearchContext() || (phaseResult instanceof QuerySearchResult q && q.isReduced() && q.getContextId() != null))
94+
&& (phaseResult.hasSearchContext()
95+
|| (phaseResult instanceof QuerySearchResult q && q.isPartiallyReduced() && q.getContextId() != null))
9596
&& context.getRequest().scroll() == null
9697
&& (context.isPartOfPointInTime(phaseResult.getContextId()) == false)) {
9798
try {

server/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,16 @@ public QuerySearchResult queryResult() {
143143
return this;
144144
}
145145

146-
public boolean isReduced() {
146+
/**
147+
* @return true if this result was already partially reduced on the data node that it originated on
148+
*/
149+
public boolean isPartiallyReduced() {
147150
return reduced;
148151
}
149152

150-
public void setReduced() {
153+
public void markAsPartiallyReduced() {
151154
assert (hasConsumedTopDocs() || topDocsAndMaxScore.topDocs.scoreDocs.length == 0) && aggregations == null
152-
: topDocsAndMaxScore + " " + aggregations;
155+
: "result not yet partially reduced [" + topDocsAndMaxScore + "][" + aggregations + "]";
153156
this.reduced = true;
154157
}
155158

0 commit comments

Comments
 (0)