Important: #105007 - Manipulation of final search query in EXT:indexed_search
See forge#105007
Description
By removing the
search option in
forge#97530, there might have been performance implications for installations
with a lot of sites. This could be circumvented by adjusting the search query
manually, using available hooks. Since those hooks have also been removed with
forge#102937, developers were no longer be able to handle the query
behaviour.
Therefore, the PSR-14
Before has been
introduced which allows developers to manipulate the
Query
instance again, just before the query gets executed.
Additional context information, provided by the new event:
search- The corresponding search words listWords free- Pointer to which indexing configuration should be searched in. -1 means no filtering. 0 means only regular indexed content.Index Uid
Important
The provided query (the
Query instance) is controlled by
TYPO3 and is not considered public API. Therefore, developers using this
event need to keep track of underlying changes by TYPO3. Such changes might
be further performance improvements to the query or changes to the
database schema in general.
Example
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\IndexedSearch\Event\BeforeFinalSearchQueryIsExecutedEvent;
final readonly class EventListener
{
#[AsEventListener(identifier: 'manipulate-search-query')]
public function beforeFinalSearchQueryIsExecuted(BeforeFinalSearchQueryIsExecutedEvent $event): void
{
$event->queryBuilder->andWhere(
$event->queryBuilder->expr()->eq('some_column', 'some_value')
);
}
}