search without accent

This commit is contained in:
simon lehericey 2024-12-03 12:49:25 +01:00
parent 8c17dd6e1d
commit 06a71cdf85
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 5 additions and 2 deletions

View file

@ -27,8 +27,8 @@ class DossierSearchService
end end
def self.dossier_by_full_text(dossiers, search_terms, with_annotations) def self.dossier_by_full_text(dossiers, search_terms, with_annotations)
ts_vector = "to_tsvector('french', #{with_annotations ? 'dossiers.search_terms || dossiers.private_search_terms' : 'dossiers.search_terms'})" ts_vector = "to_tsvector('french', unaccent(#{with_annotations ? 'dossiers.search_terms || dossiers.private_search_terms' : 'dossiers.search_terms'}))"
ts_query = "to_tsquery('french', #{Dossier.connection.quote(to_tsquery(search_terms))})" ts_query = "to_tsquery('french', unaccent(#{Dossier.connection.quote(to_tsquery(search_terms))}))"
dossiers dossiers
.visible_by_administration .visible_by_administration

View file

@ -58,6 +58,9 @@ describe DossierSearchService do
# by singular # by singular
expect(searching('la pomme')).to eq([dossier.id]) expect(searching('la pomme')).to eq([dossier.id])
# without accent
expect(searching('helene')).to eq([dossier.id])
end end
end end