From 6b4f9f5ea1def521ddff5f3f8a506271d602acf2 Mon Sep 17 00:00:00 2001 From: Pawel Krzaczkowski Date: Fri, 23 May 2014 13:42:58 +0200 Subject: [PATCH 1/2] Aggragations/Filter - fix for es1.2 when no sub aggregations --- lib/Elastica/Aggregation/Filter.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Elastica/Aggregation/Filter.php b/lib/Elastica/Aggregation/Filter.php index 18a9b9c211..911e92d9be 100755 --- a/lib/Elastica/Aggregation/Filter.php +++ b/lib/Elastica/Aggregation/Filter.php @@ -27,9 +27,13 @@ public function setFilter(AbstractFilter $filter) */ public function toArray() { - return array( - "filter" => $this->getParam("filter"), - "aggs" => $this->_aggs + $array = array( + "filter" => $this->getParam("filter") ); + + if($this->_aggs) + $array['aggs'] = $this->_aggs; + + return $array; } } \ No newline at end of file From 9e82b711c4aa81e5eeece34e970474d70dc7aad6 Mon Sep 17 00:00:00 2001 From: Pawel Krzaczkowski Date: Fri, 23 May 2014 13:49:29 +0200 Subject: [PATCH 2/2] Aggragations/Filter - fix for es1.2 when no sub aggregations --- lib/Elastica/Aggregation/Filter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Elastica/Aggregation/Filter.php b/lib/Elastica/Aggregation/Filter.php index 911e92d9be..c2326ffebc 100755 --- a/lib/Elastica/Aggregation/Filter.php +++ b/lib/Elastica/Aggregation/Filter.php @@ -32,7 +32,9 @@ public function toArray() ); if($this->_aggs) + { $array['aggs'] = $this->_aggs; + } return $array; }