|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\Query; |
|
4
|
|
|
|
|
5
|
|
|
/*************************************************************** |
|
6
|
|
|
* Copyright notice |
|
7
|
|
|
* |
|
8
|
|
|
* (c) 2017 <[email protected]> |
|
9
|
|
|
* All rights reserved |
|
10
|
|
|
* |
|
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
|
12
|
|
|
* free software; you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU General Public License as published by |
|
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
15
|
|
|
* (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* The GNU General Public License can be found at |
|
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
|
19
|
|
|
* |
|
20
|
|
|
* This script is distributed in the hope that it will be useful, |
|
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23
|
|
|
* GNU General Public License for more details. |
|
24
|
|
|
* |
|
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
|
26
|
|
|
***************************************************************/ |
|
27
|
|
|
|
|
28
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\BigramPhraseFields; |
|
29
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Elevation; |
|
30
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Faceting; |
|
31
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\FieldCollapsing; |
|
32
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Grouping; |
|
33
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Highlighting; |
|
34
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Operator; |
|
35
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\PhraseFields; |
|
36
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\QueryFields; |
|
37
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\ReturnFields; |
|
38
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Slops; |
|
39
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Sorting; |
|
40
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Sortings; |
|
41
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Spellchecking; |
|
42
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\TrigramPhraseFields; |
|
43
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
44
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* The AbstractQueryBuilder contains all logic to initialize solr queries independent from TYPO3. |
|
48
|
|
|
*/ |
|
49
|
|
|
abstract class AbstractQueryBuilder { |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Query |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $queryToBuild = null; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param Query $query |
|
58
|
|
|
* @return $this |
|
59
|
|
|
*/ |
|
60
|
|
|
public function startFrom(Query $query) |
|
61
|
|
|
{ |
|
62
|
127 |
|
$this->queryToBuild = $query; |
|
63
|
|
|
return $this; |
|
64
|
127 |
|
} |
|
65
|
127 |
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return Query |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getQuery(): Query |
|
70
|
|
|
{ |
|
71
|
169 |
|
return $this->queryToBuild; |
|
72
|
|
|
} |
|
73
|
169 |
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param bool $omitHeader |
|
76
|
|
|
* @return $this |
|
77
|
|
|
*/ |
|
78
|
|
|
public function useOmitHeader($omitHeader = true) |
|
79
|
|
|
{ |
|
80
|
138 |
|
$this->queryToBuild->setOmitHeader($omitHeader); |
|
81
|
|
|
|
|
82
|
138 |
|
return $this; |
|
83
|
|
|
} |
|
84
|
138 |
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Uses an array of filters and applies them to the query. |
|
87
|
|
|
* |
|
88
|
|
|
* @param array $filterArray |
|
89
|
|
|
* @return $this |
|
90
|
|
|
*/ |
|
91
|
|
|
public function useFilterArray(array $filterArray) |
|
92
|
|
|
{ |
|
93
|
140 |
|
foreach ($filterArray as $key => $additionalFilter) { |
|
94
|
|
|
$this->useFilter($additionalFilter, $key); |
|
95
|
140 |
|
} |
|
96
|
10 |
|
|
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
140 |
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Applies the queryString that is used to search |
|
102
|
|
|
* |
|
103
|
|
|
* @param string $queryString |
|
104
|
|
|
* @return $this |
|
105
|
|
|
*/ |
|
106
|
|
|
public function useQueryString($queryString) |
|
107
|
|
|
{ |
|
108
|
5 |
|
$this->queryToBuild->setQuery($queryString); |
|
109
|
|
|
return $this; |
|
110
|
5 |
|
} |
|
111
|
5 |
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Applies the passed queryType to the query. |
|
114
|
|
|
* |
|
115
|
|
|
* @param string $queryType |
|
116
|
|
|
* @return $this |
|
117
|
|
|
*/ |
|
118
|
|
|
public function useQueryType(string $queryType) |
|
119
|
|
|
{ |
|
120
|
2 |
|
$this->queryToBuild->addParam('qt', $queryType); |
|
121
|
|
|
return $this; |
|
122
|
2 |
|
} |
|
123
|
2 |
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Remove the queryType (qt) from the query. |
|
126
|
|
|
* |
|
127
|
|
|
* @return $this |
|
128
|
|
|
*/ |
|
129
|
|
|
public function removeQueryType() |
|
130
|
|
|
{ |
|
131
|
1 |
|
$this->queryToBuild->addParam('qt', null); |
|
132
|
|
|
return $this; |
|
133
|
1 |
|
} |
|
134
|
1 |
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Can be used to remove all sortings from the query. |
|
137
|
|
|
* |
|
138
|
|
|
* @return $this |
|
139
|
|
|
*/ |
|
140
|
|
|
public function removeAllSortings() |
|
141
|
|
|
{ |
|
142
|
1 |
|
$this->queryToBuild->clearSorts(); |
|
143
|
|
|
return $this; |
|
144
|
1 |
|
} |
|
145
|
1 |
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Applies the passed sorting to the query. |
|
148
|
|
|
* |
|
149
|
|
|
* @param Sorting $sorting |
|
150
|
|
|
* @return $this |
|
151
|
|
|
*/ |
|
152
|
|
|
public function useSorting(Sorting $sorting) |
|
153
|
|
|
{ |
|
154
|
7 |
|
if (strpos($sorting->getFieldName(), 'relevance') !== false) { |
|
155
|
|
|
$this->removeAllSortings(); |
|
156
|
7 |
|
return $this; |
|
157
|
1 |
|
} |
|
158
|
1 |
|
|
|
159
|
|
|
$this->queryToBuild->addSort($sorting->getFieldName(), $sorting->getDirection()); |
|
160
|
|
|
return $this; |
|
161
|
7 |
|
} |
|
162
|
7 |
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Applies the passed sorting to the query. |
|
165
|
|
|
* |
|
166
|
|
|
* @param Sortings $sortings |
|
167
|
|
|
* @return $this |
|
168
|
|
|
*/ |
|
169
|
|
|
public function useSortings(Sortings $sortings) |
|
170
|
|
|
{ |
|
171
|
6 |
|
foreach($sortings->getSortings() as $sorting) { |
|
172
|
|
|
$this->useSorting($sorting); |
|
173
|
6 |
|
} |
|
174
|
6 |
|
|
|
175
|
|
|
return $this; |
|
176
|
|
|
} |
|
177
|
6 |
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @param int $resultsPerPage |
|
180
|
|
|
* @return $this |
|
181
|
|
|
*/ |
|
182
|
|
|
public function useResultsPerPage($resultsPerPage) |
|
183
|
|
|
{ |
|
184
|
138 |
|
$this->queryToBuild->setRows($resultsPerPage); |
|
185
|
|
|
return $this; |
|
186
|
138 |
|
} |
|
187
|
138 |
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* @param int $page |
|
190
|
|
|
* @return $this |
|
191
|
|
|
*/ |
|
192
|
|
|
public function usePage($page) |
|
193
|
|
|
{ |
|
194
|
|
|
$this->queryToBuild->setStart($page); |
|
195
|
|
|
return $this; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* @param Operator $operator |
|
200
|
|
|
* @return $this |
|
201
|
|
|
*/ |
|
202
|
|
|
public function useOperator(Operator $operator) |
|
203
|
|
|
{ |
|
204
|
1 |
|
$this->queryToBuild->setQueryDefaultOperator( $operator->getOperator()); |
|
205
|
|
|
return $this; |
|
206
|
1 |
|
} |
|
207
|
1 |
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* Remove the default query operator. |
|
210
|
|
|
* |
|
211
|
|
|
* @return $this |
|
212
|
|
|
*/ |
|
213
|
|
|
public function removeOperator() |
|
214
|
|
|
{ |
|
215
|
1 |
|
$this->queryToBuild->setQueryDefaultOperator(null); |
|
216
|
|
|
return $this; |
|
217
|
1 |
|
} |
|
218
|
1 |
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @param Slops $slops |
|
221
|
|
|
* @return $this |
|
222
|
|
|
*/ |
|
223
|
|
|
public function useSlops(Slops $slops) |
|
224
|
|
|
{ |
|
225
|
56 |
|
return $slops->build($this); |
|
226
|
|
|
} |
|
227
|
56 |
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* Uses the passed boostQuer(y|ies) for the query. |
|
230
|
|
|
* |
|
231
|
|
|
* @param string|array $boostQueries |
|
232
|
|
|
* @return $this |
|
233
|
|
|
*/ |
|
234
|
|
|
public function useBoostQueries($boostQueries) |
|
235
|
|
|
{ |
|
236
|
3 |
|
$boostQueryArray = []; |
|
237
|
|
|
if(is_array($boostQueries)) { |
|
238
|
3 |
|
foreach($boostQueries as $boostQuery) { |
|
239
|
3 |
|
$boostQueryArray[] = ['key' => md5($boostQuery), 'query' => $boostQuery]; |
|
240
|
1 |
|
} |
|
241
|
1 |
|
} else { |
|
242
|
|
|
$boostQueryArray[] = ['key' => md5($boostQueries), 'query' => $boostQueries]; |
|
243
|
|
|
} |
|
244
|
2 |
|
|
|
245
|
|
|
$this->queryToBuild->getEDisMax()->setBoostQueries($boostQueryArray); |
|
246
|
|
|
return $this; |
|
247
|
3 |
|
} |
|
248
|
3 |
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Removes all boost queries from the query. |
|
251
|
|
|
* |
|
252
|
|
|
* @return $this |
|
253
|
|
|
*/ |
|
254
|
|
|
public function removeAllBoostQueries() |
|
255
|
|
|
{ |
|
256
|
1 |
|
$this->queryToBuild->getEDisMax()->clearBoostQueries(); |
|
257
|
|
|
return $this; |
|
258
|
1 |
|
} |
|
259
|
1 |
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* Uses the passed boostFunction for the query. |
|
262
|
|
|
* |
|
263
|
|
|
* @param string $boostFunction |
|
264
|
|
|
* @return $this |
|
265
|
|
|
*/ |
|
266
|
|
|
public function useBoostFunction(string $boostFunction) |
|
267
|
|
|
{ |
|
268
|
2 |
|
$this->queryToBuild->getEDisMax()->setBoostFunctions($boostFunction); |
|
269
|
|
|
return $this; |
|
270
|
2 |
|
} |
|
271
|
2 |
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Removes all previously configured boost functions. |
|
274
|
|
|
* |
|
275
|
|
|
* @return $this |
|
276
|
|
|
*/ |
|
277
|
|
|
public function removeAllBoostFunctions() |
|
278
|
|
|
{ |
|
279
|
1 |
|
$this->queryToBuild->getEDisMax()->setBoostFunctions(null); |
|
280
|
|
|
return $this; |
|
281
|
1 |
|
} |
|
282
|
1 |
|
|
|
283
|
|
|
|
|
284
|
|
|
/** |
|
285
|
|
|
* Uses the passed minimumMatch(mm) for the query. |
|
286
|
|
|
* |
|
287
|
|
|
* @param string $minimumMatch |
|
288
|
|
|
* @return $this |
|
289
|
|
|
*/ |
|
290
|
|
|
public function useMinimumMatch(string $minimumMatch) |
|
291
|
|
|
{ |
|
292
|
2 |
|
$this->queryToBuild->getEDisMax()->setMinimumMatch($minimumMatch); |
|
293
|
|
|
return $this; |
|
294
|
2 |
|
} |
|
295
|
2 |
|
|
|
296
|
|
|
/** |
|
297
|
|
|
* Remove any previous passed minimumMatch parameter. |
|
298
|
|
|
* |
|
299
|
|
|
* @return $this |
|
300
|
|
|
*/ |
|
301
|
|
|
public function removeMinimumMatch() |
|
302
|
|
|
{ |
|
303
|
1 |
|
$this->queryToBuild->getEDisMax()->setMinimumMatch(null); |
|
304
|
|
|
return $this; |
|
305
|
1 |
|
} |
|
306
|
1 |
|
|
|
307
|
|
|
|
|
308
|
|
|
/** |
|
309
|
|
|
* Applies the tie parameter to the query. |
|
310
|
|
|
* |
|
311
|
|
|
* @param mixed $tie |
|
312
|
|
|
* @return $this |
|
313
|
|
|
*/ |
|
314
|
|
|
public function useTieParameter($tie) |
|
315
|
|
|
{ |
|
316
|
1 |
|
$this->queryToBuild->getEDisMax()->setTie($tie); |
|
317
|
|
|
return $this; |
|
318
|
1 |
|
} |
|
319
|
1 |
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* Applies custom QueryFields to the query. |
|
322
|
|
|
* |
|
323
|
|
|
* @param QueryFields $queryFields |
|
324
|
|
|
* @return $this |
|
325
|
|
|
*/ |
|
326
|
|
|
public function useQueryFields(QueryFields $queryFields) |
|
327
|
|
|
{ |
|
328
|
146 |
|
return $queryFields->build($this); |
|
329
|
|
|
} |
|
330
|
146 |
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* Applies custom ReturnFields to the query. |
|
333
|
|
|
* |
|
334
|
|
|
* @param ReturnFields $returnFields |
|
335
|
|
|
* @return $this |
|
336
|
|
|
*/ |
|
337
|
|
|
public function useReturnFields(ReturnFields $returnFields) |
|
338
|
|
|
{ |
|
339
|
140 |
|
return $returnFields->build($this); |
|
340
|
|
|
} |
|
341
|
140 |
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* Can be used to use a specific filter string in the solr query. |
|
344
|
|
|
* |
|
345
|
|
|
* @param string $filterString |
|
346
|
|
|
* @param string $filterName |
|
347
|
|
|
* @return $this |
|
348
|
|
|
*/ |
|
349
|
|
|
public function useFilter($filterString, $filterName = '') |
|
350
|
|
|
{ |
|
351
|
59 |
|
$filterName = $filterName === '' ? $filterString : $filterName; |
|
352
|
|
|
|
|
353
|
59 |
|
$nameWasPassedAndFilterIsAllreadySet = $filterName !== '' && $this->queryToBuild->getFilterQuery($filterName) !== null; |
|
354
|
59 |
|
if($nameWasPassedAndFilterIsAllreadySet) { |
|
355
|
59 |
|
return $this; |
|
356
|
|
|
} |
|
357
|
|
|
$this->queryToBuild->addFilterQuery(['key' => $filterName, 'query' => $filterString]); |
|
358
|
|
|
return $this; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
/** |
|
362
|
|
|
* Removes a filter by the fieldName. |
|
363
|
|
|
* |
|
364
|
1 |
|
* @param string $fieldName |
|
365
|
|
|
* @return $this |
|
366
|
1 |
|
*/ |
|
367
|
1 |
|
public function removeFilterByFieldName($fieldName) |
|
368
|
1 |
|
{ |
|
369
|
1 |
|
return $this->removeFilterByFunction( |
|
370
|
1 |
|
function($key, $query) use ($fieldName) { |
|
371
|
1 |
|
$queryString = $query->getQuery(); |
|
372
|
|
|
$storedFieldName = substr($queryString,0, strpos($queryString, ":")); |
|
373
|
|
|
return $storedFieldName == $fieldName; |
|
374
|
|
|
} |
|
375
|
|
|
); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
/** |
|
379
|
|
|
* Removes a filter by the name of the filter (also known as key). |
|
380
|
|
|
* |
|
381
|
1 |
|
* @param string $name |
|
382
|
|
|
* @return $this |
|
383
|
1 |
|
*/ |
|
384
|
1 |
|
public function removeFilterByName($name) |
|
385
|
1 |
|
{ |
|
386
|
1 |
|
return $this->removeFilterByFunction( |
|
387
|
1 |
|
function($key, $query) use ($name) { |
|
388
|
|
|
$key = $query->getKey(); |
|
389
|
|
|
return $key == $name; |
|
390
|
|
|
} |
|
391
|
|
|
); |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
/** |
|
395
|
|
|
* Removes a filter by the filter value. |
|
396
|
|
|
* |
|
397
|
1 |
|
* @param string $value |
|
398
|
|
|
* @return $this |
|
399
|
1 |
|
*/ |
|
400
|
1 |
|
public function removeFilterByValue($value) |
|
401
|
1 |
|
{ |
|
402
|
1 |
|
return $this->removeFilterByFunction( |
|
403
|
1 |
|
function($key, $query) use ($value) { |
|
404
|
|
|
$query = $query->getQuery(); |
|
405
|
|
|
return $query == $value; |
|
406
|
|
|
} |
|
407
|
|
|
); |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
/** |
|
411
|
2 |
|
* @param \Closure $filterFunction |
|
412
|
|
|
* @return $this |
|
413
|
2 |
|
*/ |
|
414
|
2 |
|
public function removeFilterByFunction($filterFunction) |
|
415
|
2 |
|
{ |
|
416
|
2 |
|
$queries = $this->queryToBuild->getFilterQueries(); |
|
417
|
2 |
|
foreach($queries as $key => $query) { |
|
418
|
|
|
$canBeRemoved = $filterFunction($key, $query); |
|
419
|
|
|
if($canBeRemoved) { |
|
420
|
|
|
unset($queries[$key]); |
|
421
|
2 |
|
} |
|
422
|
2 |
|
} |
|
423
|
|
|
|
|
424
|
|
|
$this->queryToBuild->setFilterQueries($queries); |
|
425
|
|
|
return $this; |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
|
|
/** |
|
429
|
|
|
* Passes the alternative query to the Query |
|
430
|
42 |
|
* @param string $query |
|
431
|
|
|
* @return $this |
|
432
|
42 |
|
*/ |
|
433
|
42 |
|
public function useAlternativeQuery(string $query) |
|
434
|
|
|
{ |
|
435
|
|
|
$this->queryToBuild->getEDisMax()->setQueryAlternative($query); |
|
436
|
|
|
return $this; |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
/** |
|
440
|
|
|
* Remove the alternative query from the Query. |
|
441
|
1 |
|
* |
|
442
|
|
|
* @return $this |
|
443
|
1 |
|
*/ |
|
444
|
1 |
|
public function removeAlternativeQuery() |
|
445
|
|
|
{ |
|
446
|
|
|
$this->queryToBuild->getEDisMax()->setQueryAlternative(null); |
|
447
|
|
|
return $this; |
|
448
|
|
|
} |
|
449
|
|
|
|
|
450
|
|
|
/** |
|
451
|
|
|
* Applies a custom Faceting configuration to the query. |
|
452
|
|
|
* |
|
453
|
139 |
|
* @param Faceting $faceting |
|
454
|
|
|
* @return $this |
|
455
|
139 |
|
*/ |
|
456
|
|
|
public function useFaceting(Faceting $faceting) |
|
457
|
|
|
{ |
|
458
|
|
|
return $faceting->build($this); |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
/** |
|
462
|
139 |
|
* @param FieldCollapsing $fieldCollapsing |
|
463
|
|
|
* @return $this |
|
464
|
139 |
|
*/ |
|
465
|
|
|
public function useFieldCollapsing(FieldCollapsing $fieldCollapsing) |
|
466
|
|
|
{ |
|
467
|
|
|
return $fieldCollapsing->build($this); |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
/** |
|
471
|
|
|
* Applies a custom initialized grouping to the query. |
|
472
|
|
|
* |
|
473
|
139 |
|
* @param Grouping $grouping |
|
474
|
|
|
* @return $this |
|
475
|
139 |
|
*/ |
|
476
|
|
|
public function useGrouping(Grouping $grouping) |
|
477
|
|
|
{ |
|
478
|
|
|
return $grouping->build($this); |
|
479
|
|
|
} |
|
480
|
|
|
|
|
481
|
|
|
/** |
|
482
|
138 |
|
* @param Highlighting $highlighting |
|
483
|
|
|
* @return $this |
|
484
|
138 |
|
*/ |
|
485
|
|
|
public function useHighlighting(Highlighting $highlighting) |
|
486
|
|
|
{ |
|
487
|
|
|
return $highlighting->build($this); |
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
|
/** |
|
491
|
36 |
|
* @param boolean $debugMode |
|
492
|
|
|
* @return $this |
|
493
|
36 |
|
*/ |
|
494
|
1 |
|
public function useDebug($debugMode) |
|
495
|
1 |
|
{ |
|
496
|
1 |
|
if (!$debugMode) { |
|
497
|
|
|
$this->queryToBuild->addParam('debugQuery', null); |
|
498
|
|
|
$this->queryToBuild->addParam('echoParams', null); |
|
499
|
36 |
|
return $this; |
|
500
|
36 |
|
} |
|
501
|
|
|
|
|
502
|
36 |
|
$this->queryToBuild->addParam('debugQuery', 'true'); |
|
503
|
|
|
$this->queryToBuild->addParam('echoParams', 'all'); |
|
504
|
|
|
|
|
505
|
|
|
return $this; |
|
506
|
|
|
} |
|
507
|
|
|
|
|
508
|
|
|
/** |
|
509
|
41 |
|
* @param Elevation $elevation |
|
510
|
|
|
* @return QueryBuilder |
|
511
|
41 |
|
*/ |
|
512
|
|
|
public function useElevation(Elevation $elevation) |
|
513
|
|
|
{ |
|
514
|
|
|
return $elevation->build($this); |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
/** |
|
518
|
36 |
|
* @param Spellchecking $spellchecking |
|
519
|
|
|
* @return $this |
|
520
|
36 |
|
*/ |
|
521
|
|
|
public function useSpellchecking(Spellchecking $spellchecking) |
|
522
|
|
|
{ |
|
523
|
|
|
return $spellchecking->build($this); |
|
524
|
|
|
} |
|
525
|
|
|
|
|
526
|
|
|
/** |
|
527
|
|
|
* Applies a custom configured PhraseFields to the query. |
|
528
|
|
|
* |
|
529
|
140 |
|
* @param PhraseFields $phraseFields |
|
530
|
|
|
* @return $this |
|
531
|
140 |
|
*/ |
|
532
|
|
|
public function usePhraseFields(PhraseFields $phraseFields) |
|
533
|
|
|
{ |
|
534
|
|
|
return $phraseFields->build($this); |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
/** |
|
538
|
|
|
* Applies a custom configured BigramPhraseFields to the query. |
|
539
|
|
|
* |
|
540
|
139 |
|
* @param BigramPhraseFields $bigramPhraseFields |
|
541
|
|
|
* @return $this |
|
542
|
139 |
|
*/ |
|
543
|
|
|
public function useBigramPhraseFields(BigramPhraseFields $bigramPhraseFields) |
|
544
|
|
|
{ |
|
545
|
|
|
return $bigramPhraseFields->build($this); |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
/** |
|
549
|
|
|
* Applies a custom configured TrigramPhraseFields to the query. |
|
550
|
|
|
* |
|
551
|
139 |
|
* @param TrigramPhraseFields $trigramPhraseFields |
|
552
|
|
|
* @return $this |
|
553
|
139 |
|
*/ |
|
554
|
|
|
public function useTrigramPhraseFields(TrigramPhraseFields $trigramPhraseFields) |
|
555
|
|
|
{ |
|
556
|
|
|
return $trigramPhraseFields->build($this); |
|
557
|
|
|
} |
|
558
|
|
|
} |
|
559
|
|
|
|