Elastica\QueryBuilder::aggregation PHP Method

aggregation() public method

Aggregation DSL.
public aggregation ( ) : Aggregation
return Elastica\QueryBuilder\DSL\Aggregation
    public function aggregation()
    {
        return $this->_facades[DSL::TYPE_AGGREGATION];
    }

Usage Example

 /**
  * @group unit
  */
 public function testFacadeException()
 {
     $qb = new QueryBuilder(new QueryBuilder\Version\Version100());
     // undefined
     $exceptionMessage = '';
     try {
         $qb->query()->invalid();
     } catch (QueryBuilderException $exception) {
         $exceptionMessage = $exception->getMessage();
     }
     $this->assertEquals('undefined query "invalid"', $exceptionMessage);
     // unsupported
     $exceptionMessage = '';
     try {
         $qb->aggregation()->top_hits('top_hits');
     } catch (QueryBuilderException $exception) {
         $exceptionMessage = $exception->getMessage();
     }
     $this->assertEquals('aggregation "top_hits" in Version100 not supported', $exceptionMessage);
 }