Terms.php 919 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Elastica\Aggregation;
  3. /**
  4. * Class Terms.
  5. *
  6. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
  7. */
  8. class Terms extends AbstractTermsAggregation
  9. {
  10. /**
  11. * Set the bucket sort order.
  12. *
  13. * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
  14. * @param string $direction "asc" or "desc"
  15. *
  16. * @return $this
  17. */
  18. public function setOrder($order, $direction)
  19. {
  20. return $this->setParam('order', [$order => $direction]);
  21. }
  22. /**
  23. * Sets a list of bucket sort orders.
  24. *
  25. * @param array $orders a list of [<aggregationField>|"_count"|"_term" => <direction>] definitions
  26. *
  27. * @return $this
  28. */
  29. public function setOrders(array $orders)
  30. {
  31. return $this->setParam('order', $orders);
  32. }
  33. }