1 | <?php |
---|
2 | /** |
---|
3 | * Copyright 2011 Bas de Nooijer. All rights reserved. |
---|
4 | * |
---|
5 | * Redistribution and use in source and binary forms, with or without |
---|
6 | * modification, are permitted provided that the following conditions are met: |
---|
7 | * |
---|
8 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
9 | * this list of conditions and the following disclaimer. |
---|
10 | * |
---|
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
12 | * this listof conditions and the following disclaimer in the documentation |
---|
13 | * and/or other materials provided with the distribution. |
---|
14 | * |
---|
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" |
---|
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
---|
19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
25 | * POSSIBILITY OF SUCH DAMAGE. |
---|
26 | * |
---|
27 | * The views and conclusions contained in the software and documentation are |
---|
28 | * those of the authors and should not be interpreted as representing official |
---|
29 | * policies, either expressed or implied, of the copyright holder. |
---|
30 | * |
---|
31 | * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> |
---|
32 | * @license http://github.com/basdenooijer/solarium/raw/master/COPYING |
---|
33 | * @link http://www.solarium-project.org/ |
---|
34 | * |
---|
35 | * @package Solarium |
---|
36 | * @subpackage Query |
---|
37 | */ |
---|
38 | |
---|
39 | /** |
---|
40 | * DisMax component |
---|
41 | * |
---|
42 | * @link http://wiki.apache.org/solr/DisMaxQParserPlugin |
---|
43 | * |
---|
44 | * @package Solarium |
---|
45 | * @subpackage Query |
---|
46 | */ |
---|
47 | class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Component |
---|
48 | { |
---|
49 | |
---|
50 | /** |
---|
51 | * Component type |
---|
52 | * |
---|
53 | * @var string |
---|
54 | */ |
---|
55 | protected $_type = Solarium_Query_Select::COMPONENT_DISMAX; |
---|
56 | |
---|
57 | /** |
---|
58 | * Default options |
---|
59 | * |
---|
60 | * @var array |
---|
61 | */ |
---|
62 | protected $_options = array( |
---|
63 | 'queryparser' => 'dismax', |
---|
64 | ); |
---|
65 | |
---|
66 | /** |
---|
67 | * Set QueryAlternative option |
---|
68 | * |
---|
69 | * If specified, this query will be used (and parsed by default using |
---|
70 | * standard query parsing syntax) when the main query string is not |
---|
71 | * specified or blank. |
---|
72 | * |
---|
73 | * @param string $queryAlternative |
---|
74 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
75 | */ |
---|
76 | public function setQueryAlternative($queryAlternative) |
---|
77 | { |
---|
78 | return $this->_setOption('queryalternative', $queryAlternative); |
---|
79 | } |
---|
80 | |
---|
81 | /** |
---|
82 | * Get QueryAlternative option |
---|
83 | * |
---|
84 | * @return string|null |
---|
85 | */ |
---|
86 | public function getQueryAlternative() |
---|
87 | { |
---|
88 | return $this->getOption('queryalternative'); |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * Set QueryFields option |
---|
93 | * |
---|
94 | * List of fields and the "boosts" to associate with each of them when |
---|
95 | * building DisjunctionMaxQueries from the user's query. |
---|
96 | * |
---|
97 | * The format supported is "fieldOne^2.3 fieldTwo fieldThree^0.4" |
---|
98 | * |
---|
99 | * @param string $queryFields |
---|
100 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
101 | */ |
---|
102 | public function setQueryFields($queryFields) |
---|
103 | { |
---|
104 | return $this->_setOption('queryfields', $queryFields); |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * Get QueryFields option |
---|
109 | * |
---|
110 | * @return string|null |
---|
111 | */ |
---|
112 | public function getQueryFields() |
---|
113 | { |
---|
114 | return $this->getOption('queryfields'); |
---|
115 | } |
---|
116 | |
---|
117 | /** |
---|
118 | * Set MinimumMatch option |
---|
119 | * |
---|
120 | * This option makes it possible to say that a certain minimum number of |
---|
121 | * clauses must match. See Solr manual for details. |
---|
122 | * |
---|
123 | * @param string $minimumMatch |
---|
124 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
125 | */ |
---|
126 | public function setMinimumMatch($minimumMatch) |
---|
127 | { |
---|
128 | return $this->_setOption('minimummatch', $minimumMatch); |
---|
129 | } |
---|
130 | |
---|
131 | /** |
---|
132 | * Get MinimumMatch option |
---|
133 | * |
---|
134 | * @return string|null |
---|
135 | */ |
---|
136 | public function getMinimumMatch() |
---|
137 | { |
---|
138 | return $this->getOption('minimummatch'); |
---|
139 | } |
---|
140 | |
---|
141 | /** |
---|
142 | * Set PhraseFields option |
---|
143 | * |
---|
144 | * This param can be used to "boost" the score of documents in cases |
---|
145 | * where all of the terms in the "q" param appear in close proximity. |
---|
146 | * |
---|
147 | * Format is: "fieldA^1.0 fieldB^2.2" |
---|
148 | * |
---|
149 | * @param string $phraseFields |
---|
150 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
151 | */ |
---|
152 | public function setPhraseFields($phraseFields) |
---|
153 | { |
---|
154 | return $this->_setOption('phrasefields', $phraseFields); |
---|
155 | } |
---|
156 | |
---|
157 | /** |
---|
158 | * Get PhraseFields option |
---|
159 | * |
---|
160 | * @return string|null |
---|
161 | */ |
---|
162 | public function getPhraseFields() |
---|
163 | { |
---|
164 | return $this->getOption('phrasefields'); |
---|
165 | } |
---|
166 | |
---|
167 | /** |
---|
168 | * Set PhraseSlop option |
---|
169 | * |
---|
170 | * Amount of slop on phrase queries built for "pf" fields |
---|
171 | * (affects boosting) |
---|
172 | * |
---|
173 | * @param string $phraseSlop |
---|
174 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
175 | */ |
---|
176 | public function setPhraseSlop($phraseSlop) |
---|
177 | { |
---|
178 | return $this->_setOption('phraseslop', $phraseSlop); |
---|
179 | } |
---|
180 | |
---|
181 | /** |
---|
182 | * Get PhraseSlop option |
---|
183 | * |
---|
184 | * @return string|null |
---|
185 | */ |
---|
186 | public function getPhraseSlop() |
---|
187 | { |
---|
188 | return $this->getOption('phraseslop'); |
---|
189 | } |
---|
190 | |
---|
191 | /** |
---|
192 | * Set QueryPhraseSlop option |
---|
193 | * |
---|
194 | * Amount of slop on phrase queries explicitly included in the user's |
---|
195 | * query string (in qf fields; affects matching) |
---|
196 | * |
---|
197 | * @param string $queryPhraseSlop |
---|
198 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
199 | */ |
---|
200 | public function setQueryPhraseSlop($queryPhraseSlop) |
---|
201 | { |
---|
202 | return $this->_setOption('queryphraseslop', $queryPhraseSlop); |
---|
203 | } |
---|
204 | |
---|
205 | /** |
---|
206 | * Get QueryPhraseSlop option |
---|
207 | * |
---|
208 | * @return string|null |
---|
209 | */ |
---|
210 | public function getQueryPhraseSlop() |
---|
211 | { |
---|
212 | return $this->getOption('queryphraseslop'); |
---|
213 | } |
---|
214 | |
---|
215 | /** |
---|
216 | * Set Tie option |
---|
217 | * |
---|
218 | * Float value to use as tiebreaker in DisjunctionMaxQueries |
---|
219 | * |
---|
220 | * @param float $tie |
---|
221 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
222 | */ |
---|
223 | public function setTie($tie) |
---|
224 | { |
---|
225 | return $this->_setOption('tie', $tie); |
---|
226 | } |
---|
227 | |
---|
228 | /** |
---|
229 | * Get Tie option |
---|
230 | * |
---|
231 | * @return float|null |
---|
232 | */ |
---|
233 | public function getTie() |
---|
234 | { |
---|
235 | return $this->getOption('tie'); |
---|
236 | } |
---|
237 | |
---|
238 | /** |
---|
239 | * Set BoostQuery option |
---|
240 | * |
---|
241 | * A raw query string (in the SolrQuerySyntax) that will be included |
---|
242 | * with the user's query to influence the score. |
---|
243 | * |
---|
244 | * @param string $boostQuery |
---|
245 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
246 | */ |
---|
247 | public function setBoostQuery($boostQuery) |
---|
248 | { |
---|
249 | return $this->_setOption('boostquery', $boostQuery); |
---|
250 | } |
---|
251 | |
---|
252 | /** |
---|
253 | * Get BoostQuery option |
---|
254 | * |
---|
255 | * @return string|null |
---|
256 | */ |
---|
257 | public function getBoostQuery() |
---|
258 | { |
---|
259 | return $this->getOption('boostquery'); |
---|
260 | } |
---|
261 | |
---|
262 | /** |
---|
263 | * Set BoostFunctions option |
---|
264 | * |
---|
265 | * Functions (with optional boosts) that will be included in the |
---|
266 | * user's query to influence the score. |
---|
267 | * |
---|
268 | * Format is: "funcA(arg1,arg2)^1.2 funcB(arg3,arg4)^2.2" |
---|
269 | * |
---|
270 | * @param string $boostFunctions |
---|
271 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
272 | */ |
---|
273 | public function setBoostFunctions($boostFunctions) |
---|
274 | { |
---|
275 | return $this->_setOption('boostfunctions', $boostFunctions); |
---|
276 | } |
---|
277 | |
---|
278 | /** |
---|
279 | * Get BoostFunctions option |
---|
280 | * |
---|
281 | * @return string|null |
---|
282 | */ |
---|
283 | public function getBoostFunctions() |
---|
284 | { |
---|
285 | return $this->getOption('boostfunctions'); |
---|
286 | } |
---|
287 | |
---|
288 | /** |
---|
289 | * Set QueryParser option |
---|
290 | * |
---|
291 | * Can be used to enable edismax |
---|
292 | * |
---|
293 | * @since 2.1.0 |
---|
294 | * |
---|
295 | * @param string $parser |
---|
296 | * @return Solarium_Query_Select_Component_DisMax Provides fluent interface |
---|
297 | */ |
---|
298 | public function setQueryParser($parser) |
---|
299 | { |
---|
300 | return $this->_setOption('queryparser', $parser); |
---|
301 | } |
---|
302 | |
---|
303 | /** |
---|
304 | * Get QueryParser option |
---|
305 | * |
---|
306 | * @since 2.1.0 |
---|
307 | * |
---|
308 | * @return string |
---|
309 | */ |
---|
310 | public function getQueryParser() |
---|
311 | { |
---|
312 | return $this->getOption('queryparser'); |
---|
313 | } |
---|
314 | |
---|
315 | } |
---|