1<?php
2
3namespace Elastica\Processor;
4
5/**
6 * Elastica KV Processor.
7 *
8 * @author Federico Panini <fpanini@gmail.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/kv-processor.html
11 */
12class Kv extends AbstractProcessor
13{
14    const DEFAULT_TARGET_FIELD_VALUE = null;
15    const DEFAULT_IGNORE_MISSING_VALUE = false;
16
17    /**
18     * Kv constructor.
19     *
20     * @param string $field
21     * @param string $fieldSplit
22     * @param string $valueSplit
23     */
24    public function __construct(string $field, string $fieldSplit, string $valueSplit)
25    {
26        $this->setField($field);
27        $this->setFieldSplit($fieldSplit);
28        $this->setValueSplit($valueSplit);
29    }
30
31    /**
32     * Set field name.
33     *
34     * @param string $field
35     *
36     * @return $this
37     */
38    public function setField(string $field): self
39    {
40        return $this->setParam('field', $field);
41    }
42
43    /**
44     * Set field_split.
45     *
46     * @param string $fieldSplit
47     *
48     * @return $this
49     */
50    public function setFieldSplit(string $fieldSplit): self
51    {
52        return $this->setParam('field_split', $fieldSplit);
53    }
54
55    /**
56     * Set value_split.
57     *
58     * @param string $valueSplit
59     *
60     * @return $this
61     */
62    public function setValueSplit(string $valueSplit): self
63    {
64        return $this->setParam('value_split', $valueSplit);
65    }
66
67    /**
68     * Set target_field. Default value null.
69     *
70     * @param string $targetField
71     *
72     * @return $this
73     */
74    public function setTargetField(string $targetField): self
75    {
76        return $this->setParam('target_field', $targetField);
77    }
78
79    /**
80     * Set include_keys.
81     *
82     * @param array $listOfKeys
83     *
84     * @return $this
85     */
86    public function setIncludeKeys(array $listOfKeys): self
87    {
88        return $this->setParam('include_keys', $listOfKeys);
89    }
90
91    /**
92     * Set exclude_keys.
93     *
94     * @param array $listOfKeys
95     *
96     * @return $this
97     */
98    public function setExcludeKeys(array $listOfKeys): self
99    {
100        return $this->setParam('exclude_keys', $listOfKeys);
101    }
102
103    /**
104     * Set ignore_missing. Default value false.
105     *
106     * @param bool $ignoreMissing only these values are allowed (integer|float|string|boolean|auto)
107     *
108     * @return $this
109     */
110    public function setIgnoreMissing(bool $ignoreMissing): self
111    {
112        return $this->setParam('ignore_missing', $ignoreMissing);
113    }
114}
115