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 KvProcessor extends AbstractProcessor
13{
14    use Traits\FieldTrait;
15    use Traits\IgnoreFailureTrait;
16    use Traits\IgnoreMissingTrait;
17    use Traits\TargetFieldTrait;
18
19    public const DEFAULT_TARGET_FIELD_VALUE = null;
20    public const DEFAULT_IGNORE_MISSING_VALUE = false;
21
22    public function __construct(string $field, string $fieldSplit, string $valueSplit)
23    {
24        $this->setField($field);
25        $this->setFieldSplit($fieldSplit);
26        $this->setValueSplit($valueSplit);
27    }
28
29    /**
30     * Set field_split.
31     *
32     * @return $this
33     */
34    public function setFieldSplit(string $fieldSplit): self
35    {
36        return $this->setParam('field_split', $fieldSplit);
37    }
38
39    /**
40     * Set value_split.
41     *
42     * @return $this
43     */
44    public function setValueSplit(string $valueSplit): self
45    {
46        return $this->setParam('value_split', $valueSplit);
47    }
48
49    /**
50     * Set include_keys.
51     *
52     * @return $this
53     */
54    public function setIncludeKeys(array $listOfKeys): self
55    {
56        return $this->setParam('include_keys', $listOfKeys);
57    }
58
59    /**
60     * Set exclude_keys.
61     *
62     * @return $this
63     */
64    public function setExcludeKeys(array $listOfKeys): self
65    {
66        return $this->setParam('exclude_keys', $listOfKeys);
67    }
68}
69