Skip to content

Commit 1130d65

Browse files
authored
Disable concurrent aggs for Diversified Sampler and Sampler aggs (opensearch-project#11087)
Signed-off-by: Jay Deng <jayd0104@gmail.com>
1 parent 54fa050 commit 1130d65

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
125125
- Add instrumentation for indexing in transport bulk action and transport shard bulk action. ([#10273](https://github.com/opensearch-project/OpenSearch/pull/10273))
126126
- [BUG] Disable sort optimization for HALF_FLOAT ([#10999](https://github.com/opensearch-project/OpenSearch/pull/10999))
127127
- Performance improvement for MultiTerm Queries on Keyword fields ([#7057](https://github.com/opensearch-project/OpenSearch/issues/7057))
128+
- Disable concurrent aggs for Diversified Sampler and Sampler aggs ([#11087](https://github.com/opensearch-project/OpenSearch/issues/11087))
128129

129130
### Deprecated
130131

server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333

3434
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
3535

36-
import org.opensearch.action.admin.indices.refresh.RefreshRequest;
3736
import org.opensearch.action.search.SearchResponse;
3837
import org.opensearch.action.search.SearchType;
38+
import org.opensearch.action.support.WriteRequest;
3939
import org.opensearch.common.settings.Settings;
4040
import org.opensearch.common.util.FeatureFlags;
4141
import org.opensearch.index.query.TermQueryBuilder;
@@ -132,13 +132,14 @@ public void setupSuiteScopeCluster() throws Exception {
132132
client().prepareIndex("test")
133133
.setId("" + i)
134134
.setSource("author", parts[5], "name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3]))
135+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
135136
.get();
136137
client().prepareIndex("idx_unmapped_author")
137138
.setId("" + i)
138139
.setSource("name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3]))
140+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
139141
.get();
140142
}
141-
client().admin().indices().refresh(new RefreshRequest("test")).get();
142143
}
143144

144145
public void testIssue10719() throws Exception {
@@ -221,10 +222,6 @@ public void testNestedDiversity() throws Exception {
221222
}
222223

223224
public void testNestedSamples() throws Exception {
224-
assumeFalse(
225-
"Concurrent search case muted pending fix: https://github.com/opensearch-project/OpenSearch/issues/10046",
226-
internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING)
227-
);
228225
// Test samples nested under samples
229226
int MAX_DOCS_PER_AUTHOR = 1;
230227
int MAX_DOCS_PER_GENRE = 2;

server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
3636

37-
import org.opensearch.action.admin.indices.refresh.RefreshRequest;
3837
import org.opensearch.action.search.SearchResponse;
3938
import org.opensearch.action.search.SearchType;
39+
import org.opensearch.action.support.WriteRequest;
4040
import org.opensearch.common.settings.Settings;
4141
import org.opensearch.common.util.FeatureFlags;
4242
import org.opensearch.index.query.TermQueryBuilder;
@@ -132,13 +132,14 @@ public void setupSuiteScopeCluster() throws Exception {
132132
client().prepareIndex("test")
133133
.setId("" + i)
134134
.setSource("author", parts[5], "name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3]))
135+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
135136
.get();
136137
client().prepareIndex("idx_unmapped_author")
137138
.setId("" + i)
138139
.setSource("name", parts[2], "genre", parts[8], "price", Float.parseFloat(parts[3]))
140+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
139141
.get();
140142
}
141-
client().admin().indices().refresh(new RefreshRequest("test")).get();
142143
}
143144

144145
public void testIssue10719() throws Exception {
@@ -195,6 +196,23 @@ public void testSimpleSampler() throws Exception {
195196
assertThat(maxBooksPerAuthor, equalTo(3L));
196197
}
197198

199+
public void testSimpleSamplerShardSize() throws Exception {
200+
final int SHARD_SIZE = randomIntBetween(1, 3);
201+
SamplerAggregationBuilder sampleAgg = sampler("sample").shardSize(SHARD_SIZE);
202+
sampleAgg.subAggregation(terms("authors").field("author"));
203+
SearchResponse response = client().prepareSearch("test")
204+
.setSearchType(SearchType.QUERY_THEN_FETCH)
205+
.setQuery(new TermQueryBuilder("genre", "fantasy"))
206+
.setFrom(0)
207+
.setSize(60)
208+
.addAggregation(sampleAgg)
209+
.get();
210+
assertSearchResponse(response);
211+
Sampler sample = response.getAggregations().get("sample");
212+
Terms authors = sample.getAggregations().get("authors");
213+
assertEquals(SHARD_SIZE * NUM_SHARDS, sample.getDocCount());
214+
}
215+
198216
public void testUnmappedChildAggNoDiversity() throws Exception {
199217
SamplerAggregationBuilder sampleAgg = sampler("sample").shardSize(100);
200218
sampleAgg.subAggregation(terms("authors").field("author"));

server/src/main/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedAggregatorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ public InternalAggregation buildEmptyAggregation() {
162162

163163
@Override
164164
protected boolean supportsConcurrentSegmentSearch() {
165-
return true;
165+
return false;
166166
}
167167
}

server/src/main/java/org/opensearch/search/aggregations/bucket/sampler/SamplerAggregatorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ public Aggregator createInternal(
7575

7676
@Override
7777
protected boolean supportsConcurrentSegmentSearch() {
78-
return true;
78+
return false;
7979
}
8080
}

0 commit comments

Comments
 (0)