15
15
import org .elasticsearch .search .SearchHit ;
16
16
import org .elasticsearch .search .aggregations .AggregationBuilders ;
17
17
import org .elasticsearch .search .aggregations .InternalAggregation ;
18
+ import org .elasticsearch .search .aggregations .bucket .SingleBucketAggregation ;
18
19
import org .elasticsearch .search .aggregations .bucket .terms .Terms ;
19
20
import org .elasticsearch .search .aggregations .metrics .Sum ;
20
21
import org .elasticsearch .search .aggregations .metrics .TopHits ;
@@ -47,7 +48,7 @@ public void testSimpleChildrenAgg() {
47
48
assertNoFailuresAndResponse (
48
49
prepareSearch ("test" ).setQuery (matchQuery ("randomized" , true )).addAggregation (children ("to_comment" , "comment" )),
49
50
response -> {
50
- Children childrenAgg = response .getAggregations ().get ("to_comment" );
51
+ SingleBucketAggregation childrenAgg = response .getAggregations ().get ("to_comment" );
51
52
assertThat ("Response: " + response + "\n " , childrenAgg .getDocCount (), equalTo (count ));
52
53
}
53
54
);
@@ -73,7 +74,7 @@ public void testChildrenAggs() {
73
74
assertThat (categoryBucket .getKeyAsString (), equalTo (entry1 .getKey ()));
74
75
assertThat (categoryBucket .getDocCount (), equalTo ((long ) entry1 .getValue ().articleIds .size ()));
75
76
76
- Children childrenBucket = categoryBucket .getAggregations ().get ("to_comment" );
77
+ SingleBucketAggregation childrenBucket = categoryBucket .getAggregations ().get ("to_comment" );
77
78
assertThat (childrenBucket .getName (), equalTo ("to_comment" ));
78
79
assertThat (childrenBucket .getDocCount (), equalTo ((long ) entry1 .getValue ().commentIds .size ()));
79
80
assertThat (
@@ -113,7 +114,7 @@ public void testParentWithMultipleBuckets() {
113
114
114
115
for (Terms .Bucket bucket : categoryTerms .getBuckets ()) {
115
116
logger .info ("bucket={}" , bucket .getKey ());
116
- Children childrenBucket = bucket .getAggregations ().get ("to_comment" );
117
+ SingleBucketAggregation childrenBucket = bucket .getAggregations ().get ("to_comment" );
117
118
TopHits topHits = childrenBucket .getAggregations ().get ("top_comments" );
118
119
logger .info ("total_hits={}" , topHits .getHits ().getTotalHits ().value ());
119
120
for (SearchHit searchHit : topHits .getHits ()) {
@@ -125,7 +126,7 @@ public void testParentWithMultipleBuckets() {
125
126
assertThat (categoryBucket .getKeyAsString (), equalTo ("a" ));
126
127
assertThat (categoryBucket .getDocCount (), equalTo (3L ));
127
128
128
- Children childrenBucket = categoryBucket .getAggregations ().get ("to_comment" );
129
+ SingleBucketAggregation childrenBucket = categoryBucket .getAggregations ().get ("to_comment" );
129
130
assertThat (childrenBucket .getName (), equalTo ("to_comment" ));
130
131
assertThat (childrenBucket .getDocCount (), equalTo (2L ));
131
132
TopHits topHits = childrenBucket .getAggregations ().get ("top_comments" );
@@ -178,7 +179,7 @@ public void testWithDeletes() throws Exception {
178
179
assertNoFailuresAndResponse (
179
180
prepareSearch (indexName ).addAggregation (children ("children" , "child" ).subAggregation (sum ("counts" ).field ("count" ))),
180
181
response -> {
181
- Children children = response .getAggregations ().get ("children" );
182
+ SingleBucketAggregation children = response .getAggregations ().get ("children" );
182
183
assertThat (children .getDocCount (), equalTo (4L ));
183
184
184
185
Sum count = children .getAggregations ().get ("counts" );
@@ -205,7 +206,7 @@ public void testWithDeletes() throws Exception {
205
206
206
207
public void testNonExistingChildType () throws Exception {
207
208
assertNoFailuresAndResponse (prepareSearch ("test" ).addAggregation (children ("non-existing" , "xyz" )), response -> {
208
- Children children = response .getAggregations ().get ("non-existing" );
209
+ SingleBucketAggregation children = response .getAggregations ().get ("non-existing" );
209
210
assertThat (children .getName (), equalTo ("non-existing" ));
210
211
assertThat (children .getDocCount (), equalTo (0L ));
211
212
});
@@ -264,7 +265,7 @@ public void testPostCollection() throws Exception {
264
265
response -> {
265
266
assertHitCount (response , 1L );
266
267
267
- Children childrenAgg = response .getAggregations ().get ("my-refinements" );
268
+ SingleBucketAggregation childrenAgg = response .getAggregations ().get ("my-refinements" );
268
269
assertThat (childrenAgg .getDocCount (), equalTo (7L ));
269
270
270
271
Terms termsAgg = childrenAgg .getAggregations ().get ("my-colors" );
@@ -316,7 +317,7 @@ public void testHierarchicalChildrenAggs() {
316
317
response -> {
317
318
assertHitCount (response , 1L );
318
319
319
- Children children = response .getAggregations ().get (parentType );
320
+ SingleBucketAggregation children = response .getAggregations ().get (parentType );
320
321
assertThat (children .getName (), equalTo (parentType ));
321
322
assertThat (children .getDocCount (), equalTo (1L ));
322
323
children = children .getAggregations ().get (childType );
@@ -379,7 +380,7 @@ public void testPostCollectAllLeafReaders() throws Exception {
379
380
assertThat (parents .getBuckets ().size (), equalTo (2 ));
380
381
assertThat (parents .getBuckets ().get (0 ).getKeyAsString (), equalTo ("Alice" ));
381
382
assertThat (parents .getBuckets ().get (0 ).getDocCount (), equalTo (1L ));
382
- Children children = parents .getBuckets ().get (0 ).getAggregations ().get ("child_docs" );
383
+ SingleBucketAggregation children = parents .getBuckets ().get (0 ).getAggregations ().get ("child_docs" );
383
384
assertThat (children .getDocCount (), equalTo (1L ));
384
385
385
386
assertThat (parents .getBuckets ().get (1 ).getKeyAsString (), equalTo ("Bill" ));
0 commit comments