From acc4647346ecb112eb31bdf55c3f2dd999c64bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 29 Nov 2021 23:24:34 +0100 Subject: [PATCH] [person search] increase pertinence when person's lastname starts with search pattern --- CHANGELOG.md | 1 + .../Repository/PersonACLAwareRepository.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb6eb8ed6..ec27da83d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to * [person search] fix bug when using birthdate after and birthdate before +* [person search] increase pertinence when lastname begins with search pattern ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index d80a8f7d5..2cb7f9b6a 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -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 ' .