From ddbe4104589ca68bc40f3e1e7d1859ff03e0749d Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Mon, 8 Sep 2025 13:16:01 -0400 Subject: [PATCH 1/9] Add IT for num_reduce_phases coverage in batched --- .../test/search/120_batch_reduce_size.yml | 3 - .../action/search/BatchedQueryPhaseIT.java | 107 ++++++++++++++++++ .../SearchQueryThenFetchAsyncAction.java | 4 + 3 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml index 8554c7277bb07..4b2307ef79bc1 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml @@ -1,7 +1,4 @@ setup: - - skip: - awaits_fix: "TODO fix this test, the response with batched execution is not deterministic enough for the available matchers" - - do: indices.create: index: test_1 diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java new file mode 100644 index 0000000000000..292932a2d04c9 --- /dev/null +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java @@ -0,0 +1,107 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.action.search; + +import org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction.NodeQueryRequest; +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.plugins.NetworkPlugin; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.transport.TransportInterceptor; +import org.elasticsearch.transport.TransportRequest; +import org.elasticsearch.transport.TransportRequestHandler; +import org.junit.Before; + +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.Executor; + +import static org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction.NODE_SEARCH_ACTION_NAME; +import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH; +import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse; +import static org.hamcrest.Matchers.equalTo; + +public class BatchedQueryPhaseIT extends ESIntegTestCase { + + // All the batched query requests that were made in each test + private static final List batchedQueryRequests = new CopyOnWriteArrayList<>(); + + @Before + public void clear() { + batchedQueryRequests.clear(); + } + + public static class BatchedQueryCapturePlugin extends Plugin implements NetworkPlugin { + @Override + public List getTransportInterceptors( + NamedWriteableRegistry namedWriteableRegistry, + ThreadContext threadContext + ) { + return List.of(new TransportInterceptor() { + @Override + public TransportRequestHandler interceptHandler( + String action, + Executor executor, + boolean forceExecution, + TransportRequestHandler actualHandler + ) { + if (NODE_SEARCH_ACTION_NAME.equals(action)) { + return (request, channel, task) -> { + batchedQueryRequests.add((NodeQueryRequest) request); + actualHandler.messageReceived(request, channel, task); + }; + } + return actualHandler; + } + }); + } + } + + @Override + protected Collection> nodePlugins() { + return List.of(BatchedQueryCapturePlugin.class); + } + + /** + * num_reduce_phases tracks the number of times a partial reduction occurs on the coordinating node. + * This test must be aware of how batched queries are executed because reductions on the data nodes are + * not counted. + */ + public void testNumReducePhases() { + assertAcked(prepareCreate("test-idx").setMapping("title", "type=keyword")); + for (int i = 0; i < 100; i++) { + prepareIndex("test-idx").setId(Integer.toString(i)).setSource("title", "testing" + i).get(); + } + refresh(); + + assertNoFailuresAndResponse( + prepareSearch("test-idx").setBatchedReduceSize(2).addAggregation(terms("terms").field("title")).setSearchType(QUERY_THEN_FETCH), + response -> { + final int totalShards = response.getTotalShards(); + final List shardsPerDataNode = batchedQueryRequests.stream() + .map(nodeQueryRequest -> nodeQueryRequest.shards().size()) + .toList(); + final int coordNodeShards = totalShards - shardsPerDataNode.stream().mapToInt(Integer::intValue).sum(); + + // Because batched_reduce_size = 2, whenever two or more shard results exist on the coordinating node, they will be + // partially reduced. This reduction happens when either: + // - The search fans out directly to shards on the coordinating node + // - A batched result comes back + // Hence the formula: (# of shards on the coordinating node) + (# of batched requests) - 1 + final int expectedNumReducePhases = Math.max(1, coordNodeShards + shardsPerDataNode.size() - 1); + assertThat(response.getNumReducePhases(), equalTo(expectedNumReducePhases)); + } + ); + } +} diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java b/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java index a8f22eb1cc572..11c9250bd2da7 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java @@ -350,6 +350,10 @@ public String[] indices() { public IndicesOptions indicesOptions() { return searchRequest.indicesOptions(); } + + public List shards() { + return shards; + } } private record ShardToQuery(float boost, String[] originalIndices, int shardIndex, ShardId shardId, ShardSearchContextId contextId) From c7a564ad11df8cbc0946b5753d806bd522b65798 Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Tue, 16 Sep 2025 08:19:58 +0400 Subject: [PATCH 2/9] Correct assertion, reduce scope of field exposed in NodeQueryRequest --- .../action/search/BatchedQueryPhaseIT.java | 16 +++++++--------- .../action/search/QueryPhaseResultConsumer.java | 1 + .../search/SearchQueryThenFetchAsyncAction.java | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java index 292932a2d04c9..b4723b5e50d08 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java @@ -89,17 +89,15 @@ public void testNumReducePhases() { prepareSearch("test-idx").setBatchedReduceSize(2).addAggregation(terms("terms").field("title")).setSearchType(QUERY_THEN_FETCH), response -> { final int totalShards = response.getTotalShards(); - final List shardsPerDataNode = batchedQueryRequests.stream() - .map(nodeQueryRequest -> nodeQueryRequest.shards().size()) - .toList(); - final int coordNodeShards = totalShards - shardsPerDataNode.stream().mapToInt(Integer::intValue).sum(); + final int numShardsBatched = batchedQueryRequests.stream() + .map(NodeQueryRequest::numShards) + .mapToInt(Integer::intValue) + .sum(); + final int coordNodeShards = totalShards - numShardsBatched; // Because batched_reduce_size = 2, whenever two or more shard results exist on the coordinating node, they will be - // partially reduced. This reduction happens when either: - // - The search fans out directly to shards on the coordinating node - // - A batched result comes back - // Hence the formula: (# of shards on the coordinating node) + (# of batched requests) - 1 - final int expectedNumReducePhases = Math.max(1, coordNodeShards + shardsPerDataNode.size() - 1); + // partially reduced (batched queries do not count). Hence, the formula: (# of shards on the coordinating node) - 1. + final int expectedNumReducePhases = Math.max(1, coordNodeShards - 1); assertThat(response.getNumReducePhases(), equalTo(expectedNumReducePhases)); } ); diff --git a/server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java b/server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java index ec63d38616153..4e59ab6344121 100644 --- a/server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java +++ b/server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java @@ -95,6 +95,7 @@ public class QueryPhaseResultConsumer extends ArraySearchPhaseResults shards() { - return shards; + int numShards() { + return shards.size(); } } From 15f2c1350fd23a67913213d72f0fb34be5ccb616 Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Tue, 16 Sep 2025 10:00:29 +0400 Subject: [PATCH 3/9] Deduce batched shards from cluster state --- .../action/search/BatchedQueryPhaseIT.java | 126 ++++++++---------- 1 file changed, 57 insertions(+), 69 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java index b4723b5e50d08..2ac7603658a3c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java @@ -9,23 +9,19 @@ package org.elasticsearch.action.search; -import org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction.NodeQueryRequest; -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.plugins.NetworkPlugin; -import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.IndexMetadata; +import org.elasticsearch.cluster.metadata.ProjectId; +import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.cluster.routing.IndexShardRoutingTable; +import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.transport.TransportInterceptor; -import org.elasticsearch.transport.TransportRequest; -import org.elasticsearch.transport.TransportRequestHandler; -import org.junit.Before; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.Executor; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; -import static org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction.NODE_SEARCH_ACTION_NAME; import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; @@ -34,72 +30,64 @@ public class BatchedQueryPhaseIT extends ESIntegTestCase { - // All the batched query requests that were made in each test - private static final List batchedQueryRequests = new CopyOnWriteArrayList<>(); - - @Before - public void clear() { - batchedQueryRequests.clear(); - } - - public static class BatchedQueryCapturePlugin extends Plugin implements NetworkPlugin { - @Override - public List getTransportInterceptors( - NamedWriteableRegistry namedWriteableRegistry, - ThreadContext threadContext - ) { - return List.of(new TransportInterceptor() { - @Override - public TransportRequestHandler interceptHandler( - String action, - Executor executor, - boolean forceExecution, - TransportRequestHandler actualHandler - ) { - if (NODE_SEARCH_ACTION_NAME.equals(action)) { - return (request, channel, task) -> { - batchedQueryRequests.add((NodeQueryRequest) request); - actualHandler.messageReceived(request, channel, task); - }; - } - return actualHandler; - } - }); - } - } - - @Override - protected Collection> nodePlugins() { - return List.of(BatchedQueryCapturePlugin.class); - } - - /** - * num_reduce_phases tracks the number of times a partial reduction occurs on the coordinating node. - * This test must be aware of how batched queries are executed because reductions on the data nodes are - * not counted. - */ public void testNumReducePhases() { - assertAcked(prepareCreate("test-idx").setMapping("title", "type=keyword")); + String indexName = "test-idx"; + assertAcked( + prepareCreate(indexName).setMapping("title", "type=keyword") + .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)) + ); for (int i = 0; i < 100; i++) { - prepareIndex("test-idx").setId(Integer.toString(i)).setSource("title", "testing" + i).get(); + prepareIndex(indexName).setId(Integer.toString(i)).setSource("title", "testing" + i).get(); } refresh(); + final String coordinatorNode = internalCluster().getRandomNodeName(); + final String coordinatorNodeId = getNodeId(coordinatorNode); assertNoFailuresAndResponse( - prepareSearch("test-idx").setBatchedReduceSize(2).addAggregation(terms("terms").field("title")).setSearchType(QUERY_THEN_FETCH), + client(coordinatorNode).prepareSearch(indexName) + .setBatchedReduceSize(2) + .addAggregation(terms("terms").field("title")) + .setSearchType(QUERY_THEN_FETCH), response -> { - final int totalShards = response.getTotalShards(); - final int numShardsBatched = batchedQueryRequests.stream() - .map(NodeQueryRequest::numShards) - .mapToInt(Integer::intValue) - .sum(); - final int coordNodeShards = totalShards - numShardsBatched; + Map shardsPerNode = getNodeToShardCountMap(indexName); + System.out.println("testing123 " + shardsPerNode); + // Shards are not batched if they are already on the coordinating node or if there is only one per data node. + final int coordinatorShards = shardsPerNode.getOrDefault(coordinatorNodeId, 0); + final long otherSingleShardNodes = shardsPerNode.entrySet() + .stream() + .filter(entry -> entry.getKey().equals(coordinatorNodeId) == false) + .filter(entry -> entry.getValue() == 1) + .count(); + final int numNotBatchedShards = coordinatorShards + (int) otherSingleShardNodes; // Because batched_reduce_size = 2, whenever two or more shard results exist on the coordinating node, they will be - // partially reduced (batched queries do not count). Hence, the formula: (# of shards on the coordinating node) - 1. - final int expectedNumReducePhases = Math.max(1, coordNodeShards - 1); + // partially reduced (batched queries do not count towards num_reduce_phases). + // Hence, the formula: (# of NOT batched shards) - 1. + final int expectedNumReducePhases = Math.max(1, numNotBatchedShards - 1); assertThat(response.getNumReducePhases(), equalTo(expectedNumReducePhases)); } ); } + + private Map getNodeToShardCountMap(String indexName) { + ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(); + IndexRoutingTable indexRoutingTable = clusterState.routingTable(ProjectId.DEFAULT).index(indexName); + if (indexRoutingTable == null) { + return Collections.emptyMap(); + } + + Map nodeToShardCount = new HashMap<>(); + for (int shardId = 0; shardId < indexRoutingTable.size(); shardId++) { + IndexShardRoutingTable shardRoutingTable = indexRoutingTable.shard(shardId); + for (int copy = 0; copy < shardRoutingTable.size(); copy++) { + ShardRouting shardRouting = shardRoutingTable.shard(copy); + String nodeId = shardRouting.currentNodeId(); + if (nodeId != null) { + nodeToShardCount.merge(nodeId, 1, Integer::sum); + } + } + } + + return nodeToShardCount; + } } From 722f620c9e7f275f9b056da96e01326a54677990 Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Tue, 16 Sep 2025 10:01:33 +0400 Subject: [PATCH 4/9] Remove new getter - no longer needed --- .../org/elasticsearch/action/search/BatchedQueryPhaseIT.java | 2 +- .../action/search/SearchQueryThenFetchAsyncAction.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java index 2ac7603658a3c..b052ad1546671 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java @@ -24,7 +24,7 @@ import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAgcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse; import static org.hamcrest.Matchers.equalTo; diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java b/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java index a2bf304791380..a8f22eb1cc572 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java @@ -350,10 +350,6 @@ public String[] indices() { public IndicesOptions indicesOptions() { return searchRequest.indicesOptions(); } - - int numShards() { - return shards.size(); - } } private record ShardToQuery(float boost, String[] originalIndices, int shardIndex, ShardId shardId, ShardSearchContextId contextId) From 452884ebfd6e87d574a44ce6abefca3346eec010 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Tue, 16 Sep 2025 06:09:10 +0000 Subject: [PATCH 5/9] [CI] Auto commit changes from spotless --- .../org/elasticsearch/action/search/BatchedQueryPhaseIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java index b052ad1546671..39b3e09ec85bb 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java @@ -24,7 +24,6 @@ import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAgcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse; import static org.hamcrest.Matchers.equalTo; From eb5028a148bebdd075c113cd54cc78c485df1082 Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Tue, 16 Sep 2025 10:30:02 +0400 Subject: [PATCH 6/9] Typo --- .../org/elasticsearch/action/search/BatchedQueryPhaseIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java index 39b3e09ec85bb..2ac7603658a3c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java @@ -24,6 +24,7 @@ import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse; import static org.hamcrest.Matchers.equalTo; From 4f2abf8b5281a45defa75ead00ce92ab89b8a349 Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Tue, 16 Sep 2025 10:48:49 +0400 Subject: [PATCH 7/9] Typo --- .../org/elasticsearch/action/search/BatchedQueryPhaseIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java index 2ac7603658a3c..4e7199fdded63 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/BatchedQueryPhaseIT.java @@ -50,7 +50,6 @@ public void testNumReducePhases() { .setSearchType(QUERY_THEN_FETCH), response -> { Map shardsPerNode = getNodeToShardCountMap(indexName); - System.out.println("testing123 " + shardsPerNode); // Shards are not batched if they are already on the coordinating node or if there is only one per data node. final int coordinatorShards = shardsPerNode.getOrDefault(coordinatorNodeId, 0); final long otherSingleShardNodes = shardsPerNode.entrySet() From 6afe28acac59b24b6201d9c3563c4b1e8a8240e7 Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Wed, 17 Sep 2025 12:29:57 +0400 Subject: [PATCH 8/9] Add assertion that num_reduce_phases >= 1 --- .../rest-api-spec/test/search/120_batch_reduce_size.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml index 4b2307ef79bc1..c35eb0dc00d54 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml @@ -48,6 +48,7 @@ setup: batched_reduce_size: 2 body: { "size" : 0, "aggs" : { "str_terms" : { "terms" : { "field" : "str" } } } } + - gte: { num_reduce_phases: 1 } - match: { hits.total: 3 } - length: { aggregations.str_terms.buckets: 2 } - match: { aggregations.str_terms.buckets.0.key: "abc" } From eccb29d55be3347a578e47ef560226dffd0e82cb Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Wed, 17 Sep 2025 12:56:08 +0400 Subject: [PATCH 9/9] Revert "Add assertion that num_reduce_phases >= 1" This reverts commit 6afe28acac59b24b6201d9c3563c4b1e8a8240e7. --- .../rest-api-spec/test/search/120_batch_reduce_size.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml index c35eb0dc00d54..4b2307ef79bc1 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/120_batch_reduce_size.yml @@ -48,7 +48,6 @@ setup: batched_reduce_size: 2 body: { "size" : 0, "aggs" : { "str_terms" : { "terms" : { "field" : "str" } } } } - - gte: { num_reduce_phases: 1 } - match: { hits.total: 3 } - length: { aggregations.str_terms.buckets: 2 } - match: { aggregations.str_terms.buckets.0.key: "abc" }