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