File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -59,17 +59,21 @@ public function getIterator() : \ArrayIterator
5959 public function toArray () : array
6060 {
6161 $ array = [];
62+ $ hasFilter = $ this ->filter && \count ($ this ->filter ->toArray ());
6263
6364 foreach ($ this ->aggregations as $ aggregation ) {
6465 if ($ aggregation instanceof \Spameri \ElasticQuery \Aggregation \LeafAggregationCollection) {
6566 $ array [$ this ->key ()]['aggregations ' ][$ aggregation ->key ()] = $ aggregation ->toArray ()[$ aggregation ->key ()];
6667
67- } else {
68+ } elseif ( $ hasFilter ) {
6869 $ array [$ this ->key ()]['aggregations ' ][$ aggregation ->key ()] = $ aggregation ->toArray ();
70+
71+ } else {
72+ $ array [$ this ->key ()] = $ aggregation ->toArray ();
6973 }
7074 }
7175
72- if ($ this -> filter ) {
76+ if ($ hasFilter ) {
7377 $ array [$ this ->key ()]['filter ' ] = $ this ->filter ->toArray ();
7478 }
7579
You can’t perform that action at this time.
0 commit comments