Skip to content

Commit

Permalink
Merge pull request #555 from krzaczek/master
Browse files Browse the repository at this point in the history
Global Aggregation
  • Loading branch information
ruflin committed Feb 18, 2014
2 parents 0770bb8 + 6340b35 commit 42d91ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CHANGES
2014-02-17
- Throw PartialShardFailureException if response has failed shards
- Issue #555: Elastica/Aggregations/GlobalAggragation not allowed as sub aggragation

2014-02-14
- Add methods setSize, setShardSize to Elastica/Aggregation/Terms
Expand Down
7 changes: 6 additions & 1 deletion lib/Elastica/Aggregation/AbstractAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Elastica\Aggregation;


use Elastica\Param;
use Elastica\Exception\InvalidException;

abstract class AbstractAggregation extends Param
{
Expand Down Expand Up @@ -57,10 +57,15 @@ public function getAggs()
/**
* Add a sub-aggregation
* @param AbstractAggregation $aggregation
* @throws \Elastica\Exception\InvalidException
* @return AbstractAggregation
*/
public function addAggregation(AbstractAggregation $aggregation)
{
if(is_a($aggregation, 'Elastica\Aggregation\GlobalAggregation')) {
throw new InvalidException('Global aggregators can only be placed as top level aggregators');
}

$this->_aggs[$aggregation->getName()] = $aggregation->toArray();
return $this;
}
Expand Down

0 comments on commit 42d91ed

Please sign in to comment.