1<?php
2
3namespace Elastica\Processor;
4
5/**
6 * Elastica Rename Processor.
7 *
8 * @author Federico Panini <fpanini@gmail.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rename-processor.html
11 */
12class Rename extends AbstractProcessor
13{
14    const DEFAULT_IGNORE_MISSING_VALUE = false;
15
16    /**
17     * Rename constructor.
18     *
19     * @param string $field
20     * @param string $targetField
21     */
22    public function __construct(string $field, string $targetField)
23    {
24        $this->setField($field);
25        $this->setTargetField($targetField);
26    }
27
28    /**
29     * Set field.
30     *
31     * @param string $field
32     *
33     * @return $this
34     */
35    public function setField(string $field): self
36    {
37        return $this->setParam('field', $field);
38    }
39
40    /**
41     * Set target_field.
42     *
43     * @param string $targetField
44     *
45     * @return $this
46     */
47    public function setTargetField(string $targetField): self
48    {
49        return $this->setParam('target_field', $targetField);
50    }
51
52    /**
53     * Set ignore_missing. Default value false.
54     *
55     * @param bool $ignoreMissing only these values are allowed (integer|float|string|boolean|auto)
56     *
57     * @return $this
58     */
59    public function setIgnoreMissing(bool $ignoreMissing): self
60    {
61        return $this->setParam('ignore_missing', $ignoreMissing);
62    }
63}
64