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

[TASK] improve locations search: handle multiple search terms

parent ede6f530
......@@ -31,7 +31,15 @@ class Events implements MiddlewareInterface
return $response;
}
$tableName = 'tx_sfeventmgt_domain_model_location';
$searchPhrase = $request->getQueryParams()['eventLocationSearch'];
// results in AGAINST( '+sword1* +sword2*') - does only match words _beginning_ with sword (not anywhere)
$searchPhrase = '+' . implode(
'* +',
GeneralUtility::trimExplode(
' ',
$request->getQueryParams()['eventLocationSearch'],
true
)
) . '*';
$searchColumns = [
$tableName . '.`title`',
$tableName . '.`address`',
......@@ -53,7 +61,7 @@ class Events implements MiddlewareInterface
->from($tableName)
->where(
'MATCH (' . implode(',', $searchColumns) . ')'
. ' AGAINST (' . $queryBuilder->createNamedParameter($searchPhrase . '*')
. ' AGAINST (' . $queryBuilder->createNamedParameter($searchPhrase)
. ' IN BOOLEAN MODE)'
)
->setMaxResults(10)
......
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