Skip to content

Commit 2c355ce

Browse files
authored
Disable concurrent search path for composite aggregations (opensearch-project#12380)
For more details see: opensearch-project#12331 Signed-off-by: Sorabh Hamirwasia <sohami.apache@gmail.com>
1 parent d26b0be commit 2c355ce

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed

release-notes/opensearch.release-notes-2.12.0.md

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
- [Query Insights] Implement Top N Queries feature to collect and gather information about high latency queries in a window ([#11904](https://github.com/opensearch-project/OpenSearch/pull/11904))
143143
- Add override support for sampling based on action ([#9621](https://github.com/opensearch-project/OpenSearch/issues/9621))
144144
- Added custom sampler support based on transport action in request ([#9621](https://github.com/opensearch-project/OpenSearch/issues/9621))
145+
- Disable concurrent search for composite aggregation([#12375](https://github.com/opensearch-project/OpenSearch/pull/12375))
145146

146147
### Removed
147148
- Remove deprecated classes for Rounding ([#10956](https://github.com/opensearch-project/OpenSearch/issues/10956))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.search.aggregations.bucket;
10+
11+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
12+
13+
import org.opensearch.action.search.SearchResponse;
14+
import org.opensearch.cluster.health.ClusterHealthStatus;
15+
import org.opensearch.cluster.metadata.IndexMetadata;
16+
import org.opensearch.common.settings.Settings;
17+
import org.opensearch.search.aggregations.bucket.composite.CompositeAggregationBuilder;
18+
import org.opensearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
19+
import org.opensearch.search.aggregations.bucket.composite.TermsValuesSourceBuilder;
20+
import org.opensearch.search.aggregations.metrics.MaxAggregationBuilder;
21+
import org.opensearch.test.OpenSearchIntegTestCase;
22+
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
23+
24+
import java.util.ArrayList;
25+
import java.util.Arrays;
26+
import java.util.Collection;
27+
import java.util.List;
28+
29+
import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;
30+
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
31+
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertSearchResponse;
32+
33+
@OpenSearchIntegTestCase.SuiteScopeTestCase
34+
public class CompositeAggIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {
35+
36+
public CompositeAggIT(Settings staticSettings) {
37+
super(staticSettings);
38+
}
39+
40+
@ParametersFactory
41+
public static Collection<Object[]> parameters() {
42+
return Arrays.asList(
43+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), false).build() },
44+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), true).build() }
45+
);
46+
}
47+
48+
@Override
49+
public void setupSuiteScopeCluster() throws Exception {
50+
assertAcked(
51+
prepareCreate(
52+
"idx",
53+
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
54+
).setMapping("type", "type=keyword", "num", "type=integer", "score", "type=integer")
55+
);
56+
waitForRelocation(ClusterHealthStatus.GREEN);
57+
58+
client().prepareIndex("idx").setId("1").setSource("type", "type1", "num", "1", "score", "5").get();
59+
client().prepareIndex("idx").setId("1").setSource("type", "type2", "num", "11", "score", "50").get();
60+
refresh("idx");
61+
client().prepareIndex("idx").setId("1").setSource("type", "type1", "num", "1", "score", "2").get();
62+
client().prepareIndex("idx").setId("1").setSource("type", "type2", "num", "12", "score", "20").get();
63+
refresh("idx");
64+
client().prepareIndex("idx").setId("1").setSource("type", "type1", "num", "3", "score", "10").get();
65+
client().prepareIndex("idx").setId("1").setSource("type", "type2", "num", "13", "score", "15").get();
66+
refresh("idx");
67+
client().prepareIndex("idx").setId("1").setSource("type", "type1", "num", "3", "score", "1").get();
68+
client().prepareIndex("idx").setId("1").setSource("type", "type2", "num", "13", "score", "100").get();
69+
refresh("idx");
70+
71+
waitForRelocation(ClusterHealthStatus.GREEN);
72+
refresh();
73+
}
74+
75+
public void testCompositeAggWithNoSubAgg() {
76+
SearchResponse rsp = client().prepareSearch("idx")
77+
.addAggregation(new CompositeAggregationBuilder("my_composite", getTestValueSources()))
78+
.get();
79+
assertSearchResponse(rsp);
80+
}
81+
82+
public void testCompositeAggWithSubAgg() {
83+
SearchResponse rsp = client().prepareSearch("idx")
84+
.addAggregation(
85+
new CompositeAggregationBuilder("my_composite", getTestValueSources()).subAggregation(
86+
new MaxAggregationBuilder("max").field("score")
87+
)
88+
)
89+
.get();
90+
assertSearchResponse(rsp);
91+
}
92+
93+
private List<CompositeValuesSourceBuilder<?>> getTestValueSources() {
94+
final List<CompositeValuesSourceBuilder<?>> sources = new ArrayList<>();
95+
sources.add(new TermsValuesSourceBuilder("keyword_vs").field("type"));
96+
sources.add(new TermsValuesSourceBuilder("num_vs").field("num"));
97+
return sources;
98+
}
99+
}

server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregationFactory.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ protected Aggregator createInternal(
8080

8181
@Override
8282
protected boolean supportsConcurrentSegmentSearch() {
83-
return true;
83+
// See https://github.com/opensearch-project/OpenSearch/issues/12331 for details
84+
return false;
8485
}
8586
}

0 commit comments

Comments
 (0)