Bugzilla – Attachment 190464 Details for
Bug 41287
Using locale sorting may have a negative impact on search speeds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41287: Add option to use simple Stringwise sorting for facets
Bug-41287-Add-option-to-use-simple-Stringwise-sort.patch (text/plain), 4.55 KB, created by
Nick Clemens (kidclamp)
on 2025-12-12 13:23:36 UTC
(
hide
)
Description:
Bug 41287: Add option to use simple Stringwise sorting for facets
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-12-12 13:23:36 UTC
Size:
4.55 KB
patch
obsolete
>From e7048d01d94c51bbf2ac7c3424599933382a1f38 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 12 Dec 2025 13:18:35 +0000 >Subject: [PATCH] Bug 41287: Add option to use simple Stringwise sorting for > facets > >This patch restores the previous perl sorting to restore speed. For English language libraries >this will be correct in most instances, and is much more performant. > >To test: >1 - Apply patch, update database >2 - Perform some searches, note ordering of facets >3 - Update system preference 'FacetOrder' to 'simple alphabetical' >4 - Peform some searches, note ordering of facets, should be correct unless you have unicode characters >5 - Sign off > >NOTE: Benchmarks attached as a comment, you can also enable NYTProf and view results for yourself: >https://wiki.koha-community.org/wiki/Profiling_with_Devel::NYTProf#NYTProf_with_Plack >--- > C4/Search.pm | 3 +++ > Koha/SearchEngine/Elasticsearch/Search.pm | 2 ++ > installer/data/mysql/mandatory/sysprefs.sql | 2 +- > .../prog/en/modules/admin/preferences/searching.pref | 5 +++-- > 4 files changed, 9 insertions(+), 3 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 23dd75db4ff..1ec3f34b022 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -587,6 +587,9 @@ sub getRecords { > $f->{facets} = $sorted_facets; > } > } >+ if ( C4::Context->preference('FacetOrder') eq 'Stringwise' ) { >+ @{ $f->{facets} } = sort { $a->{facet_label_value} cmp $b->{facet_label_value} } @{ $f->{facets} }; >+ } > } > } > >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index b0356ec8a52..ccf502c96c0 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -575,6 +575,8 @@ sub _convert_facets { > if ($sorted_facets) { > $facet->{facets} = $sorted_facets; > } >+ } elsif ( C4::Context->preference('FacetOrder') eq 'Stringwise' ) { >+ @{ $facet->{facets} } = sort { $a->{facet_label_value} cmp $b->{facet_label_value} } @{ $facet->{facets} }; > } > push @facets, $facet if exists $facet->{facets}; > } >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 35a5d15dd8f..734150ba931 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -281,7 +281,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('ExtendedPatronAttributes','1',NULL,'Use extended patron IDs and attributes','YesNo'), > ('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'), > ('FacetMaxCount','20',NULL,'Specify the max facet count for each category','Integer'), >-('FacetOrder','Alphabetical','Alphabetical|Usage','Specify the order of facets within each category','Choice'), >+('FacetOrder','Alphabetical','Alphabetical|Usage|Stringwise','Specify the order of facets within each category','Choice'), > ('FacetSortingLocale','default','','Choose the locale for sorting facet names when FacetOrder is set to Alphabetical. This enables proper Unicode-aware sorting of accented characters and locale-specific alphabetical ordering.','Choice'), > ('FailedLoginAttempts','','','Number of login attempts before lockout the patron account','Integer'), > ('FallbackToSMSIfNoEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >index 6c7e8d0e78a..4c586b7621f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >@@ -301,10 +301,11 @@ Searching: > - pref: FacetOrder > type: choice > choices: >- Alphabetical: "alphabetically" >+ Alphabetical: "alphabetically using locale" > Usage: "by usage count" >+ Stringwise: "simple alphabetical" > default: Alphabetical >- - for each category. >+ - for each category. Locale can be set using the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FacetSortingLocale">FacetSortingLocale</a> preference. > - > - By default, show > - pref: OPACnumSearchResults >-- >2.39.5
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 41287
:
189898
|
190464
|
190465
|
190470
|
190472
|
190473
|
190577
|
190578
|
190579