@@ -800,14 +800,15 @@ public void singleValuedField_OrderedBySingleValueSubAggregationAsc() throws Exc
800
800
assertThat (terms .getName (), equalTo ("terms" ));
801
801
assertThat (terms .getBuckets ().size (), equalTo (5 ));
802
802
803
- for ( int i = 0 ; i < 5 ; i ++) {
804
- Terms .Bucket bucket = terms .getBucketByKey ( "val" + i );
803
+ int i = 0 ;
804
+ for ( Terms .Bucket bucket : terms .getBuckets ()) {
805
805
assertThat (bucket , notNullValue ());
806
806
assertThat (key (bucket ), equalTo ("val" + i ));
807
807
assertThat (bucket .getDocCount (), equalTo (1l ));
808
808
Avg avg = bucket .getAggregations ().get ("avg_i" );
809
809
assertThat (avg , notNullValue ());
810
810
assertThat (avg .getValue (), equalTo ((double ) i ));
811
+ i ++;
811
812
}
812
813
}
813
814
@@ -911,16 +912,16 @@ public void singleValuedField_OrderedBySingleValueSubAggregationDesc() throws Ex
911
912
assertThat (terms .getName (), equalTo ("terms" ));
912
913
assertThat (terms .getBuckets ().size (), equalTo (5 ));
913
914
914
- for (int i = 4 ; i >= 0 ; i --) {
915
-
916
- Terms .Bucket bucket = terms .getBucketByKey ("val" + i );
915
+ int i = 4 ;
916
+ for (Terms .Bucket bucket : terms .getBuckets ()) {
917
917
assertThat (bucket , notNullValue ());
918
918
assertThat (key (bucket ), equalTo ("val" + i ));
919
919
assertThat (bucket .getDocCount (), equalTo (1l ));
920
920
921
921
Avg avg = bucket .getAggregations ().get ("avg_i" );
922
922
assertThat (avg , notNullValue ());
923
923
assertThat (avg .getValue (), equalTo ((double ) i ));
924
+ i --;
924
925
}
925
926
926
927
}
@@ -943,15 +944,16 @@ public void singleValuedField_OrderedByMultiValueSubAggregationAsc() throws Exce
943
944
assertThat (terms .getName (), equalTo ("terms" ));
944
945
assertThat (terms .getBuckets ().size (), equalTo (5 ));
945
946
946
- for ( int i = 0 ; i < 5 ; i ++) {
947
- Terms .Bucket bucket = terms .getBucketByKey ( "val" + i );
947
+ int i = 0 ;
948
+ for ( Terms .Bucket bucket : terms .getBuckets ()) {
948
949
assertThat (bucket , notNullValue ());
949
950
assertThat (key (bucket ), equalTo ("val" + i ));
950
951
assertThat (bucket .getDocCount (), equalTo (1l ));
951
952
952
953
Stats stats = bucket .getAggregations ().get ("stats" );
953
954
assertThat (stats , notNullValue ());
954
955
assertThat (stats .getMax (), equalTo ((double ) i ));
956
+ i ++;
955
957
}
956
958
957
959
}
@@ -974,15 +976,16 @@ public void singleValuedField_OrderedByMultiValueSubAggregationDesc() throws Exc
974
976
assertThat (terms .getName (), equalTo ("terms" ));
975
977
assertThat (terms .getBuckets ().size (), equalTo (5 ));
976
978
977
- for ( int i = 4 ; i >= 0 ; i --) {
978
- Terms .Bucket bucket = terms .getBucketByKey ( "val" + i );
979
+ int i = 4 ;
980
+ for ( Terms .Bucket bucket : terms .getBuckets ()) {
979
981
assertThat (bucket , notNullValue ());
980
982
assertThat (key (bucket ), equalTo ("val" + i ));
981
983
assertThat (bucket .getDocCount (), equalTo (1l ));
982
984
983
985
Stats stats = bucket .getAggregations ().get ("stats" );
984
986
assertThat (stats , notNullValue ());
985
987
assertThat (stats .getMax (), equalTo ((double ) i ));
988
+ i --;
986
989
}
987
990
988
991
}
@@ -994,7 +997,7 @@ public void singleValuedField_OrderedByMultiValueExtendedStatsAsc() throws Excep
994
997
.addAggregation (terms ("terms" )
995
998
.executionHint (randomExecutionHint ())
996
999
.field (SINGLE_VALUED_FIELD_NAME )
997
- .order (Terms .Order .aggregation ("stats.variance " , asc ))
1000
+ .order (Terms .Order .aggregation ("stats.sum_of_squares " , asc ))
998
1001
.subAggregation (extendedStats ("stats" ).field ("i" ))
999
1002
).execute ().actionGet ();
1000
1003
@@ -1005,15 +1008,16 @@ public void singleValuedField_OrderedByMultiValueExtendedStatsAsc() throws Excep
1005
1008
assertThat (terms .getName (), equalTo ("terms" ));
1006
1009
assertThat (terms .getBuckets ().size (), equalTo (5 ));
1007
1010
1008
- for ( int i = 0 ; i < 5 ; i ++) {
1009
- Terms .Bucket bucket = terms .getBucketByKey ( "val" + i );
1011
+ int i = 0 ;
1012
+ for ( Terms .Bucket bucket : terms .getBuckets ()) {
1010
1013
assertThat (bucket , notNullValue ());
1011
1014
assertThat (key (bucket ), equalTo ("val" + i ));
1012
1015
assertThat (bucket .getDocCount (), equalTo (1l ));
1013
1016
1014
1017
ExtendedStats stats = bucket .getAggregations ().get ("stats" );
1015
1018
assertThat (stats , notNullValue ());
1016
1019
assertThat (stats .getMax (), equalTo ((double ) i ));
1020
+ i ++;
1017
1021
}
1018
1022
1019
1023
}
0 commit comments