1<?php
2
3namespace Elastica\Processor;
4
5/**
6 * Elastica Attachment Processor.
7 *
8 * @author Federico Panini <fpanini@gmail.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html
11 */
12class Attachment extends AbstractProcessor
13{
14    const DEFAULT_TARGET_FIELD_VALUE = 'attachment';
15    const DEFAULT_INDEXED_CHARS_VALUE = 100000;
16    const DEFAULT_IGNORE_MISSING_VALUE = false;
17
18    /**
19     * Attachment constructor.
20     *
21     * @param string $field
22     */
23    public function __construct(string $field)
24    {
25        $this->setField($field);
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. Default attachment.
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 indexed_chars. Default 100000.
54     *
55     * @param int $indexedChars
56     *
57     * @return $this
58     */
59    public function setIndexedChars(int $indexedChars): self
60    {
61        return $this->setParam('indexed_chars', $indexedChars);
62    }
63
64    /**
65     * Set properties. Default all properties. Can be content, title, name, author, keywords, date, content_type, content_length, language.
66     *
67     * @param array $properties
68     *
69     * @return $this
70     */
71    public function setProperties(array $properties): self
72    {
73        return $this->setParam('properties', $properties);
74    }
75
76    /**
77     * Set ignore_missing. Default value false.
78     *
79     * @param bool $ignoreMissing
80     *
81     * @return $this
82     */
83    public function setIgnoreMissing(bool $ignoreMissing): self
84    {
85        return $this->setParam('ignore_missing', $ignoreMissing);
86    }
87}
88