Bugzilla – Attachment 167146 Details for
Bug 36947
Sort Elasticsearch facets according to system locale instead of using Perl's stringwise/bytewise sort
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36947: Remove diacritics from decomposed strings in ES search
Bug-36947-Remove-diacritics-from-decomposed-string.patch (text/plain), 2.12 KB, created by
Lari Strand
on 2024-05-24 07:03:44 UTC
(
hide
)
Description:
Bug 36947: Remove diacritics from decomposed strings in ES search
Filename:
MIME Type:
Creator:
Lari Strand
Created:
2024-05-24 07:03:44 UTC
Size:
2.12 KB
patch
obsolete
>From cc67beab3a0abc5ec1467f2f81dbf599d2143d74 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 24 May 2024 04:26:41 +0000 >Subject: [PATCH] Bug 36947: Remove diacritics from decomposed strings in ES > search >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch removes the diacritics from strings decomposed using >Unicode::Normalize's NFKD function. It's necessary to provide >equivalent sorting of accented and unaccented characters. > >Test plan: >0. Apply patch >1. koha-plack --restart kohadev >2. Switch to using Elasticsearch and reindex >koha-elasticsearch -b -v --rebuild kohadev >3. Setup some test records with authors with accented and unaccented names, >and different cases for the lead letter >e.g. Aa author, Ãa author2, aa author3 >4 Do a test search >e.g. http://localhost:8081/cgi-bin/koha/catalogue/search.pl?q=test >5. Confirm the facet names are sorted in ascending order regardless >of accent or case >e.g. >Aa author >Ãa author2 >aa author3 >Farley, David >Humble, Jez > >Signed-off-by: Lari Strand <lari.strand@koha-suomi.fi> >--- > Koha/SearchEngine/Elasticsearch/Search.pm | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index 3c0d828d4f..aa36681597 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -504,7 +504,7 @@ sub _convert_facets { > } > if( C4::Context->preference('FacetOrder') eq 'Alphabetical' ){ > @{ $facet->{facets} } = >- sort { NFKD(uc($a->{facet_label_value})) cmp NFKD(uc($b->{facet_label_value})) } @{ $facet->{facets} }; >+ sort { _normalize_str($a->{facet_label_value}) cmp _normalize_str($b->{facet_label_value}) } @{ $facet->{facets} }; > } > push @facets, $facet if exists $facet->{facets}; > } >@@ -577,4 +577,11 @@ sub _aggregation_scan { > return (undef, \%result, undef); > } > >+sub _normalize_str { >+ my ($str) = @_; >+ my $text = NFKD(uc($str)); >+ $text =~ s/\p{M}//g; >+ return $text; >+} >+ > 1; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36947
:
167110
|
167125
|
167141
|
167142
|
167143
|
167145
|
167146
|
167188
|
167198
|
167880
|
168488
|
170489