Commit ede6f530 authored by Jonas Götze's avatar Jonas Götze
Browse files

[WIP][TASK] improve locations search

todo: handle multiple search terms
parent bd69f40a
......@@ -30,9 +30,17 @@ class Events implements MiddlewareInterface
if (!isset($request->getQueryParams()['eventLocationSearch'])) {
return $response;
}
$tableName = 'tx_sfeventmgt_domain_model_location';
$searchPhrase = $request->getQueryParams()['eventLocationSearch'];
$searchColumns = [
$tableName . '.`title`',
$tableName . '.`address`',
$tableName . '.`zip`',
$tableName . '.`city`',
$tableName . '.`country`'
];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_sfeventmgt_domain_model_location')
->getConnectionForTable($tableName)
->createQueryBuilder();
$locations = $queryBuilder->select(
'uid',
......@@ -42,12 +50,11 @@ class Events implements MiddlewareInterface
'city',
'country'
)
->from('tx_sfeventmgt_domain_model_location')
->from($tableName)
->where(
$queryBuilder->expr()->like(
'title',
$queryBuilder->createNamedParameter('%' . $searchPhrase . '%')
),
'MATCH (' . implode(',', $searchColumns) . ')'
. ' AGAINST (' . $queryBuilder->createNamedParameter($searchPhrase . '*')
. ' IN BOOLEAN MODE)'
)
->setMaxResults(10)
->execute()
......
......@@ -36,3 +36,7 @@ CREATE TABLE tx_t3omembership_domain_model_member (
CREATE TABLE tx_t3omembership_domain_model_membership (
external_identifier varchar(255) DEFAULT '' NOT NULL
);
CREATE TABLE tx_sfeventmgt_domain_model_location (
FULLTEXT INDEX `fulltext` (`title`, `address`, `zip`, `city`, `country`)
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment