Sort.php 842 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Elastica\Processor;
  3. /**
  4. * Elastica Sort Processor.
  5. *
  6. * @author Federico Panini <fpanini@gmail.com>
  7. *
  8. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-processor.html
  9. */
  10. class Sort extends AbstractProcessor
  11. {
  12. /**
  13. * Split constructor.
  14. *
  15. * @param $field
  16. */
  17. public function __construct($field)
  18. {
  19. $this->setField($field);
  20. }
  21. /**
  22. * Set the field.
  23. *
  24. * @param string $field
  25. *
  26. * @return $this
  27. */
  28. public function setField(string $field)
  29. {
  30. return $this->setParam('field', $field);
  31. }
  32. /**
  33. * Set order. Default 'asc'.
  34. *
  35. * @param string $order
  36. *
  37. * @return $this
  38. */
  39. public function setOrder(string $order)
  40. {
  41. return $this->setParam('order', $order);
  42. }
  43. }