summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php
blob: ac2d01b39e4d7f2836748dee9d896f90afe3a68d (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php

namespace Elastica\Query;

/**
 * Multi Match
 *
 * @category Xodoa
 * @package Elastica
 * @author Rodolfo Adhenawer Campagnoli Moraes <adhenawer@gmail.com>
 * @author Wong Wing Lun <luiges90@gmail.com>
 * @author Tristan Maindron <tmaindron@gmail.com>
 * @link http://www.elasticsearch.org/guide/reference/query-dsl/multi-match-query.html
 */
class MultiMatch extends AbstractQuery
{
    const TYPE_BEST_FIELDS   = 'best_fields';
    const TYPE_MOST_FIELDS   = 'most_fields';
    const TYPE_CROSS_FIELDS  = 'cross_fields';
    const TYPE_PHRASE        = 'phrase';
    const TYPE_PHRASE_PREFIX = 'phrase_prefix';

    const OPERATOR_OR        = 'or';
    const OPERATOR_AND       = 'and';

    const ZERO_TERM_NONE     = 'none';
    const ZERO_TERM_ALL      = 'all';

    /**
     * Sets the query
     *
     * @param  string                         $query Query
     * @return \Elastica\Query\MultiMatch Current object
     */
    public function setQuery($query = '')
    {
        return $this->setParam('query', $query);
    }

    /**
     * Sets Fields to be used in the query.
     *
     * @param  array                          $fields Fields
     * @return \Elastica\Query\MultiMatch Current object
     */
    public function setFields($fields = array())
    {
        return $this->setParam('fields', $fields);
    }

    /**
     * Sets use dis max indicating to either create a dis_max query or a bool query.
     *
     * If not set, defaults to true.
     *
     * @param  boolean                        $useDisMax
     * @return \Elastica\Query\MultiMatch Current object
     */
    public function setUseDisMax($useDisMax = true)
    {
        return $this->setParam('use_dis_max', $useDisMax);
    }

    /**
     * Sets tie breaker to multiplier value to balance the scores between lower and higher scoring fields.
     *
     * If not set, defaults to 0.0.
     *
     * @param  float                          $tieBreaker
     * @return \Elastica\Query\MultiMatch Current object
     */
    public function setTieBreaker($tieBreaker = 0.0)
    {
        return $this->setParam('tie_breaker', $tieBreaker);
    }

    /**
     * Sets operator for Match Query
     *
     * If not set, defaults to 'or'
     *
     * @param  string                             $operator
     * @return \Elastica\Query\MultiMatch Current object
     */
    public function setOperator($operator = 'or')
    {
        return $this->setParam('operator', $operator);
    }

    /**
     * Set field minimum should match for Match Query
     *
     * @param  int                       $minimumShouldMatch
     * @return \Elastica\Query\Match
     */
    public function setMinimumShouldMatch($minimumShouldMatch)
    {
        return $this->setParam('minimum_should_match', (int) $minimumShouldMatch);
    }

    /**
     * Set zero terms query for Match Query
     *
     * If not set, default to 'none'
     *
     * @param  string                       $zeroTermQuery
     * @return \Elastica\Query\Match
     */
    public function setZeroTermsQuery($zeroTermQuery = 'none')
    {
        return $this->setParam('zero_terms_query', $zeroTermQuery);
    }

    /**
     * Set cutoff frequency for Match Query
     *
     * @param  float                       $cutoffFrequency
     * @return \Elastica\Query\Match
     */
    public function setCutoffFrequency($cutoffFrequency)
    {
        return $this->setParam('cutoff_frequency', $cutoffFrequency);
    }

    /**
     * Set type
     *
     * @param  string                    $field
     * @param  string                    $type
     * @return \Elastica\Query\Match
     */
    public function setType($type)
    {
        return $this->setParam('type', $type);
    }

    /**
     * Set fuzziness
     *
     * @param  float                     $fuzziness
     * @return \Elastica\Query\Match
     */
    public function setFuzziness($fuzziness)
    {
        return $this->setParam('fuzziness', (float) $fuzziness);
    }

    /**
     * Set prefix length
     *
     * @param  int                       $prefixLength
     * @return \Elastica\Query\Match
     */
    public function setPrefixLength($prefixLength)
    {
        return $this->setParam('prefix_length', (int) $prefixLength);
    }

    /**
     * Set max expansions
     *
     * @param  int                       $maxExpansions
     * @return \Elastica\Query\Match
     */
    public function setMaxExpansions($maxExpansions)
    {
        return $this->setParam('max_expansions', (int) $maxExpansions);
    }

    /**
     * Set analyzer
     *
     * @param  string                    $analyzer
     * @return \Elastica\Query\Match
     */
    public function setAnalyzer($analyzer)
    {
        return $this->setParam('analyzer', $analyzer);
    }
}