BucketSelector.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Elastica\Aggregation;
  3. /**
  4. * Class BucketSelector.
  5. *
  6. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html
  7. */
  8. class BucketSelector extends AbstractSimpleAggregation
  9. {
  10. /**
  11. * @param string $name
  12. * @param array|null $bucketsPath
  13. * @param string|null $script
  14. */
  15. public function __construct(string $name, array $bucketsPath = null, string $script = null)
  16. {
  17. parent::__construct($name);
  18. if (null !== $bucketsPath) {
  19. $this->setBucketsPath($bucketsPath);
  20. }
  21. if (null !== $script) {
  22. $this->setScript($script);
  23. }
  24. }
  25. /**
  26. * Set the buckets_path for this aggregation.
  27. *
  28. * @param array $bucketsPath
  29. *
  30. * @return $this
  31. */
  32. public function setBucketsPath($bucketsPath)
  33. {
  34. return $this->setParam('buckets_path', $bucketsPath);
  35. }
  36. /**
  37. * Set the gap policy for this aggregation.
  38. *
  39. * @param string $gapPolicy
  40. *
  41. * @return $this
  42. */
  43. public function setGapPolicy(string $gapPolicy = 'skip')
  44. {
  45. return $this->setParam('gap_policy', $gapPolicy);
  46. }
  47. }