1<?php 2 3namespace Elastica\Aggregation; 4 5/** 6 * Class Terms. 7 * 8 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html 9 */ 10class Terms extends AbstractTermsAggregation 11{ 12 use Traits\MissingTrait; 13 14 /** 15 * Set the bucket sort order. 16 * 17 * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field 18 * @param string $direction "asc" or "desc" 19 * 20 * @return $this 21 */ 22 public function setOrder(string $order, string $direction): self 23 { 24 return $this->setParam('order', [$order => $direction]); 25 } 26 27 /** 28 * Sets a list of bucket sort orders. 29 * 30 * @param array $orders a list of [<aggregationField>|"_count"|"_term" => <direction>] definitions 31 * 32 * @return $this 33 */ 34 public function setOrders(array $orders): self 35 { 36 return $this->setParam('order', $orders); 37 } 38 39 /** 40 * For Composite Agg. Include in the response documents without a value for a given source. 41 * 42 * @see https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-aggregations-bucket-composite-aggregation.html#_missing_bucket 43 * 44 * @return $this 45 */ 46 public function setMissingBucket(): self 47 { 48 return $this->setParam('missing_bucket', true); 49 } 50} 51