summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php
blob: 57b56964d47741daf56e437a2b11913ec0ca6775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Elastica\Aggregation;

/**
 * Class AbstractTermsAggergation.
 */
abstract class AbstractTermsAggregation extends AbstractSimpleAggregation
{
    /**
     * Set the minimum number of documents in which a term must appear in order to be returned in a bucket.
     *
     * @param int $count
     *
     * @return $this
     */
    public function setMinimumDocumentCount($count)
    {
        return $this->setParam('min_doc_count', $count);
    }

    /**
     * Filter documents to include based on a regular expression.
     *
     * @param string $pattern a regular expression
     * @param string $flags   Java Pattern flags
     *
     * @return $this
     */
    public function setInclude($pattern, $flags = null)
    {
        if (is_null($flags)) {
            return $this->setParam('include', $pattern);
        }

        return $this->setParam('include', array(
            'pattern' => $pattern,
            'flags' => $flags,
        ));
    }

    /**
     * Filter documents to exclude based on a regular expression.
     *
     * @param string $pattern a regular expression
     * @param string $flags   Java Pattern flags
     *
     * @return $this
     */
    public function setExclude($pattern, $flags = null)
    {
        if (is_null($flags)) {
            return $this->setParam('exclude', $pattern);
        }

        return $this->setParam('exclude', array(
            'pattern' => $pattern,
            'flags' => $flags,
        ));
    }

    /**
     * Sets the amount of terms to be returned.
     *
     * @param int $size The amount of terms to be returned.
     *
     * @return $this
     */
    public function setSize($size)
    {
        return $this->setParam('size', $size);
    }

    /**
     * Sets how many terms the coordinating node will request from each shard.
     *
     * @param int $shard_size The amount of terms to be returned.
     *
     * @return $this
     */
    public function setShardSize($shard_size)
    {
        return $this->setParam('shard_size', $shard_size);
    }

    /**
     * Instruct Elasticsearch to use direct field data or ordinals of the field values to execute this aggregation.
     * The execution hint will be ignored if it is not applicable.
     *
     * @param string $hint map or ordinals
     *
     * @return $this
     */
    public function setExecutionHint($hint)
    {
        return $this->setParam('execution_hint', $hint);
    }
}