Skip to content
Snippets Groups Projects
Commit 4c175d5c authored by Mantas Marcinkevičius's avatar Mantas Marcinkevičius
Browse files

added bucket script aggregation

parent 9be02f7b
No related branches found
No related tags found
No related merge requests found
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\ElasticsearchDSL\Aggregation\Pipeline;
/**
* Class representing Bucket Script Pipeline Aggregation.
*
* @link https://goo.gl/miVxcx
*/
class BucketScriptAggregation extends AbstractPipelineAggregation
{
/**
* @var string
*/
private $script;
/**
* @param string $name
* @param array $bucketsPath
* @param string $script
*/
public function __construct($name, $bucketsPath, $script = null)
{
parent::__construct($name, $bucketsPath);
$this->setScript($script);
}
/**
* @return string
*/
public function getScript()
{
return $this->script;
}
/**
* @param string $script
*/
public function setScript($script)
{
$this->script = $script;
}
/**
* {@inheritdoc}
*/
public function getType()
{
return 'bucket_script';
}
/**
* {@inheritdoc}
*/
public function getArray()
{
if (!$this->getScript()) {
throw new \LogicException(
sprintf(
'`%s` aggregation must have script set.',
$this->getName()
)
);
}
$out = [
'buckets_path' => $this->getBucketsPath(),
'script' => $this->getScript(),
];
return $out;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment