xref: /plugin/elasticsearch/vendor/ruflin/elastica/src/Aggregation/BucketSelector.php (revision d832d53af2a0f84c34c8d5f17c93ffaa85869e5d) !
1<?php
2
3namespace Elastica\Aggregation;
4
5/**
6 * Class BucketSelector.
7 *
8 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html
9 */
10class BucketSelector extends AbstractSimpleAggregation implements GapPolicyInterface
11{
12    use Traits\GapPolicyTrait;
13
14    public function __construct(string $name, ?array $bucketsPath = null, ?string $script = null)
15    {
16        parent::__construct($name);
17
18        if (null !== $bucketsPath) {
19            $this->setBucketsPath($bucketsPath);
20        }
21
22        if (null !== $script) {
23            $this->setScript($script);
24        }
25    }
26
27    /**
28     * Set the buckets_path for this aggregation.
29     *
30     * @return $this
31     */
32    public function setBucketsPath(array $bucketsPath): self
33    {
34        return $this->setParam('buckets_path', $bucketsPath);
35    }
36}
37