Completed
Pull Request — master (#1893)
by
unknown
03:38
created

AttachmentProcessor::setIgnoreMissing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Elastica\Processor;
4
5
/**
6
 * Elastica Attachment Processor.
7
 *
8
 * @author Federico Panini <[email protected]>
9
 *
10
 * @see https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html
11
 */
12
class AttachmentProcessor extends AbstractProcessor
13
{
14
    public const DEFAULT_TARGET_FIELD_VALUE = 'attachment';
15
    public const DEFAULT_INDEXED_CHARS_VALUE = 100000;
16
    public const DEFAULT_IGNORE_MISSING_VALUE = false;
17
18
    /**
19
     * Attachment constructor.
20
     */
21
    public function __construct(string $field)
22
    {
23
        $this->setField($field);
24
    }
25
26
    /**
27
     * Set field.
28
     *
29
     * @return $this
30
     */
31
    public function setField(string $field): self
32
    {
33
        return $this->setParam('field', $field);
34
    }
35
36
    /**
37
     * Set target_field. Default attachment.
38
     *
39
     * @return $this
40
     */
41
    public function setTargetField(string $targetField): self
42
    {
43
        return $this->setParam('target_field', $targetField);
44
    }
45
46
    /**
47
     * Set indexed_chars. Default 100000.
48
     *
49
     * @return $this
50
     */
51
    public function setIndexedChars(int $indexedChars): self
52
    {
53
        return $this->setParam('indexed_chars', $indexedChars);
54
    }
55
56
    /**
57
     * Set properties. Default all properties. Can be content, title, name, author, keywords, date, content_type, content_length, language.
58
     *
59
     * @return $this
60
     */
61
    public function setProperties(array $properties): self
62
    {
63
        return $this->setParam('properties', $properties);
64
    }
65
66
    /**
67
     * Set ignore_missing. Default value false.
68
     *
69
     * @return $this
70
     */
71
    public function setIgnoreMissing(bool $ignoreMissing): self
72
    {
73
        return $this->setParam('ignore_missing', $ignoreMissing);
74
    }
75
}
76