1<?php
2
3namespace Elastica\Processor;
4
5/**
6 * Elastica Json Processor.
7 *
8 * @author Federico Panini <fpanini@gmail.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/json-processor.html
11 */
12class JsonProcessor extends AbstractProcessor
13{
14    use Traits\FieldTrait;
15    use Traits\IgnoreFailureTrait;
16    use Traits\TargetFieldTrait;
17
18    public const DEFAULT_TARGET_FIELD_VALUE = 'field';
19    public const DEFAULT_ADD_TO_ROOT_VALUE = false;
20
21    public function __construct(string $field)
22    {
23        $this->setField($field);
24    }
25
26    /**
27     * Set add_to_root. Default value false.
28     *
29     * @return $this
30     */
31    public function setAddToRoot(bool $addToRoot): self
32    {
33        return $this->setParam('add_to_root', $addToRoot);
34    }
35}
36