Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ParentAggregationBuilder not to support concurrent execution #99809

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.internal.Requests;
Expand Down Expand Up @@ -43,7 +44,18 @@

public class ChildrenIT extends AbstractParentChildTestCase {

public void testChildrenAggs() throws Exception {
public void testSimpleChildrenAgg() {
final SearchRequestBuilder searchRequest = client().prepareSearch("test")
.setQuery(matchQuery("randomized", true))
.addAggregation(children("to_comment", "comment"));
final SearchResponse searchResponse = searchRequest.get();
long count = categoryToControl.values().stream().mapToLong(control -> control.commentIds.size()).sum();
assertSearchResponse(searchResponse);
Children childrenAgg = searchResponse.getAggregations().get("to_comment");
assertThat("Request: " + searchRequest + "\nResponse: " + searchResponse + "\n", childrenAgg.getDocCount(), equalTo(count));
}

public void testChildrenAggs() {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(matchQuery("randomized", true))
.addAggregation(
Expand Down Expand Up @@ -86,7 +98,7 @@ public void testChildrenAggs() throws Exception {
}
}

public void testParentWithMultipleBuckets() throws Exception {
public void testParentWithMultipleBuckets() {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(matchQuery("randomized", false))
.addAggregation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,27 @@

public class ParentIT extends AbstractParentChildTestCase {

public void testSimpleParentAgg() throws Exception {
public void testSimpleParentAgg() {
final SearchRequestBuilder searchRequest = client().prepareSearch("test")
.setSize(0)
.setQuery(matchQuery("randomized", true))
.addAggregation(parent("to_article", "comment"));
SearchResponse searchResponse = searchRequest.get();

assertSearchResponse(searchResponse);
long articlesWithComment = articleToControl.values()
.stream()
.filter(parentControl -> parentControl.commentIds.isEmpty() == false)
.count();
Parent parentAgg = searchResponse.getAggregations().get("to_article");
assertThat(
"Request: " + searchRequest + "\nResponse: " + searchResponse + "\n",
parentAgg.getDocCount(),
equalTo(articlesWithComment)
);
}

public void testSimpleParentAggWithSubAgg() {
final SearchRequestBuilder searchRequest = client().prepareSearch("test")
.setSize(10000)
.setQuery(matchQuery("randomized", true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public BucketCardinality bucketCardinality() {
return BucketCardinality.ONE;
}

@Override
public boolean supportsParallelCollection() {
return false;
}

@Override
protected ValuesSourceAggregatorFactory innerBuild(
AggregationContext context,
Expand Down