mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
change strategy for searching: use the AND between words, instead of OR
This commit is contained in:
parent
961c0a867c
commit
de4f65fede
@ -45,7 +45,7 @@ class SearchUserApiProvider implements SearchApiInterface
|
|||||||
$query
|
$query
|
||||||
->setSelectKey('user')
|
->setSelectKey('user')
|
||||||
->setSelectJsonbMetadata("jsonb_build_object('id', u.id)")
|
->setSelectJsonbMetadata("jsonb_build_object('id', u.id)")
|
||||||
->setSelectPertinence('GREATEST(SIMILARITY(LOWER(UNACCENT(?)), u.label),
|
->setSelectPertinence('3 + GREATEST(SIMILARITY(LOWER(UNACCENT(?)), u.label),
|
||||||
SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical))', [$pattern, $pattern])
|
SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical))', [$pattern, $pattern])
|
||||||
->setFromClause('users AS u')
|
->setFromClause('users AS u')
|
||||||
->setWhereClauses('
|
->setWhereClauses('
|
||||||
|
@ -133,8 +133,8 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
|
|||||||
|
|
||||||
$pertinence = [];
|
$pertinence = [];
|
||||||
$pertinenceArgs = [];
|
$pertinenceArgs = [];
|
||||||
$orWhereSearchClause = [];
|
$andWhereSearchClause = [];
|
||||||
$orWhereSearchClauseArgs = [];
|
$andWhereSearchClauseArgs = [];
|
||||||
|
|
||||||
if ('' !== $default) {
|
if ('' !== $default) {
|
||||||
foreach (explode(' ', $default) as $str) {
|
foreach (explode(' ', $default) as $str) {
|
||||||
@ -145,15 +145,15 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
|
|||||||
'(starts_with(LOWER(UNACCENT(lastname)), UNACCENT(LOWER(?))))::int';
|
'(starts_with(LOWER(UNACCENT(lastname)), UNACCENT(LOWER(?))))::int';
|
||||||
array_push($pertinenceArgs, $str, $str, $str, $str);
|
array_push($pertinenceArgs, $str, $str, $str, $str);
|
||||||
|
|
||||||
$orWhereSearchClause[] =
|
$andWhereSearchClause[] =
|
||||||
'(LOWER(UNACCENT(?)) <<% person.fullnamecanonical OR ' .
|
'(LOWER(UNACCENT(?)) <<% person.fullnamecanonical OR ' .
|
||||||
"person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%' )";
|
"person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%' )";
|
||||||
array_push($orWhereSearchClauseArgs, $str, $str);
|
array_push($andWhereSearchClauseArgs, $str, $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->andWhereClause(
|
$query->andWhereClause(
|
||||||
implode(' OR ', $orWhereSearchClause),
|
implode(' AND ', $andWhereSearchClause),
|
||||||
$orWhereSearchClauseArgs
|
$andWhereSearchClauseArgs
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$pertinence = ['1'];
|
$pertinence = ['1'];
|
||||||
|
@ -109,11 +109,11 @@ class ThirdPartyApiSearch implements SearchApiInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query
|
$query
|
||||||
->setSelectPertinence(implode(' + ', $pertinence), array_merge(
|
->setSelectPertinence(implode(' + ', $pertinence).' + 1', array_merge(
|
||||||
[],
|
[],
|
||||||
...$pertinenceArgs
|
...$pertinenceArgs
|
||||||
))
|
))
|
||||||
->andWhereClause(implode(' OR ', $wheres), array_merge(
|
->andWhereClause(implode(' AND ', $wheres), array_merge(
|
||||||
[],
|
[],
|
||||||
...$whereArgs
|
...$whereArgs
|
||||||
));
|
));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user