mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
change strategy for searching: use the AND between words, instead of OR
This commit is contained in:
@@ -133,8 +133,8 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
|
||||
|
||||
$pertinence = [];
|
||||
$pertinenceArgs = [];
|
||||
$orWhereSearchClause = [];
|
||||
$orWhereSearchClauseArgs = [];
|
||||
$andWhereSearchClause = [];
|
||||
$andWhereSearchClauseArgs = [];
|
||||
|
||||
if ('' !== $default) {
|
||||
foreach (explode(' ', $default) as $str) {
|
||||
@@ -145,15 +145,15 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
|
||||
'(starts_with(LOWER(UNACCENT(lastname)), UNACCENT(LOWER(?))))::int';
|
||||
array_push($pertinenceArgs, $str, $str, $str, $str);
|
||||
|
||||
$orWhereSearchClause[] =
|
||||
$andWhereSearchClause[] =
|
||||
'(LOWER(UNACCENT(?)) <<% person.fullnamecanonical OR ' .
|
||||
"person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%' )";
|
||||
array_push($orWhereSearchClauseArgs, $str, $str);
|
||||
array_push($andWhereSearchClauseArgs, $str, $str);
|
||||
}
|
||||
|
||||
$query->andWhereClause(
|
||||
implode(' OR ', $orWhereSearchClause),
|
||||
$orWhereSearchClauseArgs
|
||||
implode(' AND ', $andWhereSearchClause),
|
||||
$andWhereSearchClauseArgs
|
||||
);
|
||||
} else {
|
||||
$pertinence = ['1'];
|
||||
|
Reference in New Issue
Block a user