[person search] increase pertinence when person's lastname starts with

search pattern
This commit is contained in:
Julien Fastré 2021-11-29 23:24:34 +01:00
parent 54a4b48174
commit acc4647346
2 changed files with 4 additions and 2 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to
<!-- write down unreleased development here -->
* [person search] fix bug when using birthdate after and birthdate before
* [person search] increase pertinence when lastname begins with search pattern
## Test releases

View File

@ -137,8 +137,9 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
$pertinence[] =
'STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), person.fullnamecanonical) + ' .
"(person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%')::int + " .
"(EXISTS (SELECT 1 FROM unnest(string_to_array(fullnamecanonical, ' ')) AS t WHERE starts_with(t, UNACCENT(LOWER(?)))))::int";
array_push($pertinenceArgs, $str, $str, $str);
"(EXISTS (SELECT 1 FROM unnest(string_to_array(fullnamecanonical, ' ')) AS t WHERE starts_with(t, UNACCENT(LOWER(?)))))::int + " .
'(starts_with(LOWER(UNACCENT(lastname)), UNACCENT(LOWER(?))))::int';
array_push($pertinenceArgs, $str, $str, $str, $str);
$orWhereSearchClause[] =
'(LOWER(UNACCENT(?)) <<% person.fullnamecanonical OR ' .