Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Aggregation #555

Merged
merged 8 commits into from
Feb 18, 2014
3 changes: 3 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
CHANGES
2014-02-17
- Elastica/Aggregations - global aggragation not allowed as sub aggragation
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you merge in master again and add the ticket id to the change line? Like this it is easy traceable


2014-02-14
- Add methods setSize, setShardSize to Elastica/Aggregation/Terms
- Elastica/Aggregation/GlobalAggregationTest fixed bug where JSON returned [] instead of {}
Expand Down
6 changes: 5 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,14 @@ 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');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use { } also for 1 line if clauses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok no problem .. will fix that


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