Completed
Push — master ( 909d34...d3109a )
by Timo
48:57 queued 45:09
created

QueryBuilder::useInitialQueryFromTypoScript()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
cc 4
nc 4
nop 0
crap 4
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Domain\Search\Query;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2017 <[email protected]>
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 3 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\BigramPhraseFields;
28
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Elevation;
29
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Faceting;
30
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\FieldCollapsing;
31
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Filters;
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\PhraseFields;
35
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\QueryFields;
36
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\ReturnFields;
37
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Slops;
38
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Sorting;
39
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Sortings;
40
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Spellchecking;
41
use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\TrigramPhraseFields;
42
use ApacheSolrForTypo3\Solr\Domain\Site\SiteHashService;
43
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository;
44
use ApacheSolrForTypo3\Solr\FieldProcessor\PageUidToHierarchy;
45
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
46
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager;
47
use ApacheSolrForTypo3\Solr\Util;
48
use TYPO3\CMS\Core\Utility\GeneralUtility;
49
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
50
51
/**
52
 * The concrete QueryBuilder contains all TYPO3 specific initialization logic of solr queries, for TYPO3.
53
 *
54
 * @package ApacheSolrForTypo3\Solr\Domain\Search\Query
55
 */
56
class QueryBuilder extends AbstractQueryBuilder {
57
58
    /**
59
     * Additional filters, which will be added to the query, as well as to
60
     * suggest queries.
61
     *
62
     * @var array
63
     */
64
    protected $additionalFilters = [];
65
66
    /**
67
     * @var TypoScriptConfiguration
68
     */
69
    protected $typoScriptConfiguration = null;
70
71
    /**
72
     * @var SolrLogManager;
73
     */
74
    protected $logger = null;
75
76
    /**
77
     * @var SiteHashService
78
     */
79
    protected $siteHashService = null;
80
81
    /**
82
     * QueryBuilder constructor.
83
     * @param TypoScriptConfiguration|null $configuration
84
     * @param SolrLogManager|null $solrLogManager
85
     * @param SiteHashService|null $siteHashService
86
     */
87 185
    public function __construct(TypoScriptConfiguration $configuration = null, SolrLogManager $solrLogManager = null, SiteHashService $siteHashService = null)
88
    {
89 185
        $this->typoScriptConfiguration = $configuration ?? Util::getSolrConfiguration();
90 185
        $this->logger = $solrLogManager ?? GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
91 185
        $this->siteHashService = $siteHashService ?? GeneralUtility::makeInstance(SiteHashService::class);
92 185
    }
93
94
    /**
95
     * @param string $queryString
96
     * @return QueryBuilder
97
     */
98 152
    public function newSearchQuery($queryString): QueryBuilder
99
    {
100 152
        $this->queryToBuild = $this->getSearchQueryInstance($queryString);
101 152
        return $this;
102
    }
103
104
    /**
105
     * @param string $queryString
106
     * @return QueryBuilder
107
     */
108 4
    public function newSuggestQuery($queryString): QueryBuilder
109
    {
110 4
        $this->queryToBuild = $this->getSuggestQueryInstance($queryString);
111 4
        return $this;
112
    }
113
114
    /**
115
     * Initializes the Query object and SearchComponents and returns
116
     * the initialized query object, when a search should be executed.
117
     *
118
     * @param string|null $rawQuery
119
     * @param int $resultsPerPage
120
     * @param array $additionalFiltersFromRequest
121
     * @return SearchQuery
122
     */
123 141
    public function buildSearchQuery($rawQuery, $resultsPerPage = 10, array $additionalFiltersFromRequest = []) : SearchQuery
124
    {
125 141
        if ($this->typoScriptConfiguration->getLoggingQuerySearchWords()) {
126
            $this->logger->log(SolrLogManager::INFO, 'Received search query', [$rawQuery]);
127
        }
128
129
        /* @var $query SearchQuery */
130 141
        return $this->newSearchQuery($rawQuery)
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->newSearchQ...ader(false)->getQuery() returns the type ApacheSolrForTypo3\Solr\Domain\Search\Query\Query which includes types incompatible with the type-hinted return ApacheSolrForTypo3\Solr\...earch\Query\SearchQuery.
Loading history...
131 141
                ->useResultsPerPage($resultsPerPage)
132 141
                ->useReturnFieldsFromTypoScript()
133 141
                ->useQueryFieldsFromTypoScript()
134 141
                ->useInitialQueryFromTypoScript()
135 141
                ->useFiltersFromTypoScript()
136 141
                ->useFilterArray($additionalFiltersFromRequest)
137 141
                ->useFacetingFromTypoScript()
138 141
                ->useVariantsFromTypoScript()
139 141
                ->useGroupingFromTypoScript()
140 141
                ->useHighlightingFromTypoScript()
141 141
                ->usePhraseFieldsFromTypoScript()
142 141
                ->useBigramPhraseFieldsFromTypoScript()
143 141
                ->useTrigramPhraseFieldsFromTypoScript()
144 141
                ->useOmitHeader(false)
145 141
                ->getQuery();
146
    }
147
148
    /**
149
     * Builds a SuggestQuery with all applied filters.
150
     *
151
     * @param string $queryString
152
     * @param array $additionalFilters
153
     * @param integer $requestedPageId
154
     * @param string $groupList
155
     * @return SuggestQuery
156
     */
157 3
    public function buildSuggestQuery(string $queryString, array $additionalFilters, int $requestedPageId, string $groupList) : SuggestQuery
158
    {
159 3
        $this->newSuggestQuery($queryString)
160 3
            ->useFiltersFromTypoScript()
161 3
            ->useSiteHashFromTypoScript($requestedPageId)
162 3
            ->useUserAccessGroups(explode(',', $groupList))
163 3
            ->useOmitHeader();
164
165
166 3
        if (!empty($additionalFilters)) {
167
            $this->useFilterArray($additionalFilters);
168
        }
169
170 3
        return $this->queryToBuild;
171
    }
172
173
    /**
174
     * Returns Query for Search which finds document for given page.
175
     * Note: The Connection is per language as recommended in ext-solr docs.
176
     *
177
     * @return Query
178
     */
179 1
    public function buildPageQuery($pageId)
180
    {
181 1
        $siteRepository = GeneralUtility::makeInstance(SiteRepository::class);
182 1
        $site = $siteRepository->getSiteByPageId($pageId);
183
184 1
        return $this->newSearchQuery('')
185 1
            ->useQueryString('*:*')
186 1
            ->useFilter('(type:pages AND uid:' . $pageId . ') OR (*:* AND pid:' . $pageId . ' NOT type:pages)', 'type')
187 1
            ->useFilter('siteHash:' . $site->getSiteHash(), 'siteHash')
188 1
            ->useReturnFields(ReturnFields::fromString('*'))
189 1
            ->useSortings(Sortings::fromString('type asc, title asc'))
190 1
            ->useQueryType('standard')
191 1
            ->getQuery();
192
    }
193
194
    /**
195
     * Returns a query for single record
196
     *
197
     * @return Query
198
     */
199
    public function buildRecordQuery($type, $uid, $pageId): Query
200
    {
201
        $siteRepository = GeneralUtility::makeInstance(SiteRepository::class);
202
        $site = $siteRepository->getSiteByPageId($pageId);
203
204
        return $this->newSearchQuery('')
205
            ->useQueryString('*:*')
206
            ->useFilter('type:' . $type . ' AND uid:' . $uid, 'type')
207
            ->useFilter('siteHash:' . $site->getSiteHash(), 'siteHash')
208
            ->useReturnFields(ReturnFields::fromString('*'))
209
            ->useSortings(Sortings::fromString('type asc, title asc'))
210
            ->useQueryType('standard')
211
            ->getQuery();
212
    }
213
214
    /**
215
     * @return QueryBuilder
216
     */
217 51
    public function useSlopsFromTypoScript(): QueryBuilder
218
    {
219 51
        return $this->useSlops(Slops::fromTypoScriptConfiguration($this->typoScriptConfiguration));
220
    }
221
222
    /**
223
     * Uses the configured boost queries from typoscript
224
     *
225
     * @return QueryBuilder
226
     */
227 51
    public function useBoostQueriesFromTypoScript(): QueryBuilder
228
    {
229 51
        $searchConfiguration = $this->typoScriptConfiguration->getSearchConfiguration();
230
231 51
        if (!empty($searchConfiguration['query.']['boostQuery'])) {
232 1
            return $this->useBoostQueries($searchConfiguration['query.']['boostQuery']);
233
        }
234
235 50
        if (!empty($searchConfiguration['query.']['boostQuery.'])) {
236 1
            $boostQueries = $searchConfiguration['query.']['boostQuery.'];
237 1
            return $this->useBoostQueries(array_values($boostQueries));
238
        }
239
240 49
        return $this;
241
    }
242
243
    /**
244
     * Uses the configured boostFunction from the typoscript configuration.
245
     *
246
     * @return QueryBuilder
247
     */
248 51
    public function useBoostFunctionFromTypoScript(): QueryBuilder
249
    {
250 51
        $searchConfiguration = $this->typoScriptConfiguration->getSearchConfiguration();
251 51
        if (!empty($searchConfiguration['query.']['boostFunction'])) {
252 1
            return $this->useBoostFunction($searchConfiguration['query.']['boostFunction']);
253
        }
254
255 50
        return $this;
256
    }
257
258
    /**
259
     * Uses the configured minimumMatch from the typoscript configuration.
260
     *
261
     * @return QueryBuilder
262
     */
263 51
    public function useMinimumMatchFromTypoScript(): QueryBuilder
264
    {
265 51
        $searchConfiguration = $this->typoScriptConfiguration->getSearchConfiguration();
266 51
        if (!empty($searchConfiguration['query.']['minimumMatch'])) {
267 1
            return $this->useMinimumMatch($searchConfiguration['query.']['minimumMatch']);
268
        }
269
270 50
        return $this;
271
    }
272
273
    /**
274
     * @return QueryBuilder
275
     */
276 51
    public function useTieParameterFromTypoScript(): QueryBuilder
277
    {
278 51
        $searchConfiguration = $this->typoScriptConfiguration->getSearchConfiguration();
279 51
        if (empty($searchConfiguration['query.']['tieParameter'])) {
280 50
            return $this;
281
        }
282
283 1
        return $this->useTieParameter($searchConfiguration['query.']['tieParameter']);
284
    }
285
286
    /**
287
     * Applies the configured query fields from the typoscript configuration.
288
     *
289
     * @return QueryBuilder
290
     */
291 141
    public function useQueryFieldsFromTypoScript(): QueryBuilder
292
    {
293 141
        return $this->useQueryFields(QueryFields::fromString($this->typoScriptConfiguration->getSearchQueryQueryFields()));
294
    }
295
296
    /**
297
     * Applies the configured return fields from the typoscript configuration.
298
     *
299
     * @return QueryBuilder
300
     */
301 141
    public function useReturnFieldsFromTypoScript(): QueryBuilder
302
    {
303 141
        $returnFieldsArray = (array)$this->typoScriptConfiguration->getSearchQueryReturnFieldsAsArray(['*', 'score']);
304 141
        return $this->useReturnFields(ReturnFields::fromArray($returnFieldsArray));
305
    }
306
307
308
309
    /**
310
     * Can be used to apply the allowed sites from plugin.tx_solr.search.query.allowedSites to the query.
311
     *
312
     * @param int $requestedPageId
313
     * @return QueryBuilder
314
     */
315 40
    public function useSiteHashFromTypoScript(int $requestedPageId): QueryBuilder
316
    {
317 40
        $queryConfiguration = $this->typoScriptConfiguration->getObjectByPathOrDefault('plugin.tx_solr.search.query.', []);
318 40
        $allowedSites = $this->siteHashService->getAllowedSitesForPageIdAndAllowedSitesConfiguration($requestedPageId, $queryConfiguration['allowedSites']);
319 40
        return $this->useSiteHashFromAllowedSites($allowedSites);
320
    }
321
322
    /**
323
     * Can be used to apply a list of allowed sites to the query.
324
     *
325
     * @param string $allowedSites
326
     * @return QueryBuilder
327
     */
328 40
    public function useSiteHashFromAllowedSites($allowedSites): QueryBuilder
329
    {
330 40
        $isAnySiteAllowed = trim($allowedSites) === '*';
331 40
        if ($isAnySiteAllowed) {
332
            // no filter required
333 1
            return $this;
334
        }
335
336 39
        $allowedSites = GeneralUtility::trimExplode(',', $allowedSites);
337 39
        $filters = [];
338 39
        foreach ($allowedSites as $site) {
339 39
            $siteHash = $this->siteHashService->getSiteHashForDomain($site);
340 39
            $filters[] = 'siteHash:"' . $siteHash . '"';
341
        }
342
343 39
        $siteHashFilterString = implode(' OR ', $filters);
344 39
        return $this->useFilter($siteHashFilterString, 'siteHash');
345
    }
346
347
    /**
348
     * Can be used to filter the result on an applied list of user groups.
349
     *
350
     * @param array $groups
351
     * @return QueryBuilder
352
     */
353 44
    public function useUserAccessGroups(array $groups): QueryBuilder
354
    {
355 44
        $groups = array_map('intval', $groups);
356 44
        $groups[] = 0; // always grant access to public documents
357 44
        $groups = array_unique($groups);
358 44
        sort($groups, SORT_NUMERIC);
359
360 44
        $accessFilter = '{!typo3access}' . implode(',', $groups);
361 44
        $this->queryToBuild->removeFilterQuery('access');
362 44
        return $this->useFilter($accessFilter, 'access');
363
    }
364
365
    /**
366
     * Applies the configured initial query settings to set the alternative query for solr as required.
367
     *
368
     * @return QueryBuilder
369
     */
370 141
    public function useInitialQueryFromTypoScript(): QueryBuilder
371
    {
372 141
        if ($this->typoScriptConfiguration->getSearchInitializeWithEmptyQuery() || $this->typoScriptConfiguration->getSearchQueryAllowEmptyQuery()) {
373
            // empty main query, but using a "return everything"
374
            // alternative query in q.alt
375 39
            $this->useAlternativeQuery('*:*');
376
        }
377
378 141
        if ($this->typoScriptConfiguration->getSearchInitializeWithQuery()) {
379 4
            $this->useAlternativeQuery($this->typoScriptConfiguration->getSearchInitializeWithQuery());
380
        }
381
382 141
        return $this;
383
    }
384
385
    /**
386
     * Applies the configured facets from the typoscript configuration on the query.
387
     *
388
     * @return QueryBuilder
389
     */
390 141
    public function useFacetingFromTypoScript(): QueryBuilder
391
    {
392 141
        return $this->useFaceting(Faceting::fromTypoScriptConfiguration($this->typoScriptConfiguration));
393
    }
394
395
    /**
396
     * Applies the configured variants from the typoscript configuration on the query.
397
     *
398
     * @return QueryBuilder
399
     */
400 141
    public function useVariantsFromTypoScript(): QueryBuilder
401
    {
402 141
        return $this->useFieldCollapsing(FieldCollapsing::fromTypoScriptConfiguration($this->typoScriptConfiguration));
403
    }
404
405
    /**
406
     * Applies the configured groupings from the typoscript configuration to the query.
407
     *
408
     * @return QueryBuilder
409
     */
410 141
    public function useGroupingFromTypoScript(): QueryBuilder
411
    {
412 141
        return $this->useGrouping(Grouping::fromTypoScriptConfiguration($this->typoScriptConfiguration));
413
    }
414
415
    /**
416
     * Applies the configured highlighting from the typoscript configuration to the query.
417
     *
418
     * @return QueryBuilder
419
     */
420 141
    public function useHighlightingFromTypoScript(): QueryBuilder
421
    {
422 141
        return $this->useHighlighting(Highlighting::fromTypoScriptConfiguration($this->typoScriptConfiguration));
423
    }
424
425
    /**
426
     * Applies the configured filters (page section and other from typoscript).
427
     *
428
     * @return QueryBuilder
429
     */
430 143
    public function useFiltersFromTypoScript(): QueryBuilder
431
    {
432 143
        $filters = Filters::fromTypoScriptConfiguration($this->typoScriptConfiguration);
433 143
        $this->queryToBuild->setFilterQueries($filters->getValues());
434
435 143
        $this->useFilterArray($this->getAdditionalFilters());
436
437 143
        $searchQueryFilters = $this->typoScriptConfiguration->getSearchQueryFilterConfiguration();
438
439 143
        if (!is_array($searchQueryFilters) || count($searchQueryFilters) <= 0) {
0 ignored issues
show
introduced by
The condition is_array($searchQueryFilters) is always true.
Loading history...
440 139
            return $this;
441
        }
442
443
        // special filter to limit search to specific page tree branches
444 4
        if (array_key_exists('__pageSections', $searchQueryFilters)) {
445 1
            $pageIds = GeneralUtility::trimExplode(',', $searchQueryFilters['__pageSections']);
446 1
            $this->usePageSectionsFromPageIds($pageIds);
447 1
            $this->typoScriptConfiguration->removeSearchQueryFilterForPageSections();
448
        }
449
450 4
        return $this;
451
    }
452
453
    /**
454
     * Applies the configured elevation from the typoscript configuration.
455
     *
456
     * @return QueryBuilder
457
     */
458 38
    public function useElevationFromTypoScript(): QueryBuilder
459
    {
460 38
        return $this->useElevation(Elevation::fromTypoScriptConfiguration($this->typoScriptConfiguration));
461
    }
462
463
    /**
464
     * Applies the configured spellchecking from the typoscript configuration.
465
     *
466
     * @return QueryBuilder
467
     */
468 34
    public function useSpellcheckingFromTypoScript(): QueryBuilder
469
    {
470 34
        return $this->useSpellchecking(Spellchecking::fromTypoScriptConfiguration($this->typoScriptConfiguration));
471
    }
472
473
    /**
474
     * Applies the passed pageIds as __pageSection filter.
475
     *
476
     * @param array $pageIds
477
     * @return QueryBuilder
478
     */
479 1
    public function usePageSectionsFromPageIds(array $pageIds = []): QueryBuilder
480
    {
481 1
        $filters = [];
482
483
        /** @var $processor PageUidToHierarchy */
484 1
        $processor = GeneralUtility::makeInstance(PageUidToHierarchy::class);
485 1
        $hierarchies = $processor->process($pageIds);
486
487 1
        foreach ($hierarchies as $hierarchy) {
488 1
            $lastLevel = array_pop($hierarchy);
489 1
            $filters[] = 'rootline:"' . $lastLevel . '"';
490
        }
491
492 1
        $pageSectionsFilterString = implode(' OR ', $filters);
493 1
        return $this->useFilter($pageSectionsFilterString, 'pageSections');
494
    }
495
496
    /**
497
     * Applies the configured phrase fields from the typoscript configuration to the query.
498
     *
499
     * @return QueryBuilder
500
     */
501 141
    public function usePhraseFieldsFromTypoScript(): QueryBuilder
502
    {
503 141
        return $this->usePhraseFields(PhraseFields::fromTypoScriptConfiguration($this->typoScriptConfiguration));
504
    }
505
506
    /**
507
     * Applies the configured bigram phrase fields from the typoscript configuration to the query.
508
     *
509
     * @return QueryBuilder
510
     */
511 141
    public function useBigramPhraseFieldsFromTypoScript(): QueryBuilder
512
    {
513 141
        return $this->useBigramPhraseFields(BigramPhraseFields::fromTypoScriptConfiguration($this->typoScriptConfiguration));
514
    }
515
516
    /**
517
     * Applies the configured trigram phrase fields from the typoscript configuration to the query.
518
     *
519
     * @return QueryBuilder
520
     */
521 141
    public function useTrigramPhraseFieldsFromTypoScript(): QueryBuilder
522
    {
523 141
        return $this->useTrigramPhraseFields(TrigramPhraseFields::fromTypoScriptConfiguration($this->typoScriptConfiguration));
524
    }
525
526
    /**
527
     * Retrieves the configuration filters from the TypoScript configuration, except the __pageSections filter.
528
     *
529
     * @return array
530
     */
531 143
    public function getAdditionalFilters() : array
532
    {
533
        // when we've build the additionalFilter once, we could return them
534 143
        if (count($this->additionalFilters) > 0) {
535 2
            return $this->additionalFilters;
536
        }
537
538 143
        $searchQueryFilters = $this->typoScriptConfiguration->getSearchQueryFilterConfiguration();
539 143
        if (!is_array($searchQueryFilters) || count($searchQueryFilters) <= 0) {
0 ignored issues
show
introduced by
The condition is_array($searchQueryFilters) is always true.
Loading history...
540 140
            return [];
541
        }
542
543 4
        $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
544
545
        // all other regular filters
546 4
        foreach ($searchQueryFilters as $filterKey => $filter) {
547
            // the __pageSections filter should not be handled as additional filter
548 4
            if ($filterKey === '__pageSections') {
549 1
                continue;
550
            }
551
552 3
            $filterIsArray = is_array($searchQueryFilters[$filterKey]);
553 3
            if ($filterIsArray) {
554
                continue;
555
            }
556
557 3
            $hasSubConfiguration = is_array($searchQueryFilters[$filterKey . '.']);
558 3
            if ($hasSubConfiguration) {
559
                $filter = $cObj->stdWrap($searchQueryFilters[$filterKey], $searchQueryFilters[$filterKey . '.']);
560
            }
561
562 3
            $this->additionalFilters[$filterKey] = $filter;
563
        }
564
565 4
        return $this->additionalFilters;
566
    }
567
568
    /**
569
     * @param string $rawQuery
570
     * @return SearchQuery
571
     */
572 152
    protected function getSearchQueryInstance($rawQuery): SearchQuery
573
    {
574 152
        $query = GeneralUtility::makeInstance(SearchQuery::class);
575 152
        $query->setQuery($rawQuery);
576 152
        return $query;
577
    }
578
579
    /**
580
     * @param string $rawQuery
581
     * @return SuggestQuery
582
     */
583 4
    protected function getSuggestQueryInstance($rawQuery): SuggestQuery
584
    {
585 4
        $query = GeneralUtility::makeInstance(SuggestQuery::class, /** @scrutinizer ignore-type */ $rawQuery, /** @scrutinizer ignore-type */ $this->typoScriptConfiguration);
586
587 4
        return $query;
588
    }
589
}
590