Passed
Push — master ( 14b490...3d7c7d )
by Timo
23:43
created

QueryBuilder::usePageSectionsFromPageIds()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

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