File tree 2 files changed +36
-1
lines changed
src/Aggregation/Bucketing
tests/Unit/Aggregation/Bucketing
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ function ($v) {
90
90
}
91
91
);
92
92
93
- if (! empty ( $ key) ) {
93
+ if ('' !== $ key ) {
94
94
$ range ['key ' ] = $ key ;
95
95
}
96
96
Original file line number Diff line number Diff line change @@ -40,6 +40,41 @@ public function testRangeAggregationAddRange()
40
40
$ this ->assertEquals ($ result , $ aggregation ->toArray ());
41
41
}
42
42
43
+ public function testRangeAggregationAddZeroIndexedKeys ()
44
+ {
45
+ $ aggregation = new RangeAggregation ('test_agg ' );
46
+ $ aggregation ->setKeyed (true );
47
+ $ aggregation ->setField ('test_field ' );
48
+ $ aggregation ->addRange (0 , 100 , '0 ' );
49
+ $ aggregation ->addRange (100 , 200 , '1 ' );
50
+ $ aggregation ->addRange (200 , 300 );
51
+
52
+ $ result = [
53
+ 'range ' => [
54
+ 'field ' => 'test_field ' ,
55
+ 'ranges ' => [
56
+ [
57
+ 'from ' => 0 ,
58
+ 'to ' => 100 ,
59
+ 'key ' => '0 '
60
+ ],
61
+ [
62
+ 'from ' => 100 ,
63
+ 'to ' => 200 ,
64
+ 'key ' => '1 '
65
+ ],
66
+ [
67
+ 'from ' => 200 ,
68
+ 'to ' => 300
69
+ ]
70
+ ],
71
+ 'keyed ' => true
72
+ ],
73
+ ];
74
+
75
+ $ this ->assertEquals ($ result , $ aggregation ->toArray ());
76
+ }
77
+
43
78
/**
44
79
* Test addRange method with multiple values.
45
80
*/
You can’t perform that action at this time.
0 commit comments