Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
iverase committed Sep 22, 2023
1 parent 263cf6f commit 111f362
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
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 @@ -52,21 +52,20 @@ public void testSimpleParentAgg() {
);
}


public void testSimpleParentAggWithSubAgg() {
final SearchRequestBuilder searchRequest = client().prepareSearch("test")
.setSize(10000)
.setQuery(matchQuery("randomized", true))
.addAggregation(parent("to_article", "comment").subAggregation(terms("category").field("category").size(10000)));
SearchResponse searchResponse = searchRequest.get();
assertSearchResponse(searchResponse);

long articlesWithComment = articleToControl.values()
.stream()
.filter(parentControl -> parentControl.commentIds.isEmpty() == false)
.count();
final SearchRequestBuilder searchRequest = client().prepareSearch("test")
.setSize(10000)
.setQuery(matchQuery("randomized", true))
.addAggregation(parent("to_article", "comment").subAggregation(terms("category").field("category").size(10000)));
SearchResponse searchResponse = searchRequest.get();
assertSearchResponse(searchResponse);

Parent parentAgg = searchResponse.getAggregations().get("to_article");
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(),
Expand Down

0 comments on commit 111f362

Please sign in to comment.