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