Bugzilla – Attachment 136682 Details for
Bug 29632
Callnumber sorting is incorrect in Elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29632: Don't sort cn-sort numerically
Bug-29632-Dont-sort-cn-sort-numerically.patch (text/plain), 4.62 KB, created by
Nick Clemens (kidclamp)
on 2022-06-28 13:50:36 UTC
(
hide
)
Description:
Bug 29632: Don't sort cn-sort numerically
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-06-28 13:50:36 UTC
Size:
4.62 KB
patch
obsolete
>From 930cbc39fc154189886cdc9f426f3ac8efb12688 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 28 Jun 2022 13:47:45 +0000 >Subject: [PATCH] Bug 29632: Don't sort cn-sort numerically > >When defining our sort fields in we defined all as 'numeric' > >For other string containing numbers this is likely correct, however, >for callnumbers it is not. e.g. E45 should sort before E7 > >This patch adds a new 'callnumber' type and deifnes this for cn-sort and >adds to the field maping a sort without numeric set > >To test: >0 - Be using ES with Koha >1 - On records with single item, add callnumbers: > VA65 E7 R63 1984 > VA65 E7 T35 1990 > VA65 E45 R67 1985 >2 - Add public note 'shrimp' or something to make them easily searchable as a group >3 - Search for 'shrimp', sort by callnumber >4 - Note E45 comes last, it should come first >5 - Apply patch >6 - Reset ES mappings >7 - Reindex ES >8 - Repeat search >9 - Sorting should be correct when set to callnumber >--- > Koha/SearchEngine/Elasticsearch.pm | 2 ++ > .../searchengine/elasticsearch/field_config.yaml | 4 ++++ > admin/searchengine/elasticsearch/mappings.yaml | 2 +- > installer/data/mysql/atomicupdate/bug_29632.pl | 15 +++++++++++++++ > .../admin/searchengine/elasticsearch/mappings.tt | 5 +++++ > 5 files changed, 27 insertions(+), 1 deletion(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_29632.pl > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index c4f5041930..6e36695409 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -209,6 +209,8 @@ sub get_elasticsearch_mappings { > $es_type = 'stdno'; > } elsif ($type eq 'year') { > $es_type = 'year'; >+ } elsif ($type eq 'callnumber') { >+ $es_type = 'cn_sort'; > } > > if ($search) { >diff --git a/admin/searchengine/elasticsearch/field_config.yaml b/admin/searchengine/elasticsearch/field_config.yaml >index d78bdf06dd..cf90482aa2 100644 >--- a/admin/searchengine/elasticsearch/field_config.yaml >+++ b/admin/searchengine/elasticsearch/field_config.yaml >@@ -71,3 +71,7 @@ sort: > type: icu_collation_keyword > index: false > numeric: true >+ cn_sort: >+ type: icu_collation_keyword >+ index: false >+ numeric: false >diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml >index 5efeccef21..3eac85f09d 100644 >--- a/admin/searchengine/elasticsearch/mappings.yaml >+++ b/admin/searchengine/elasticsearch/mappings.yaml >@@ -1167,7 +1167,7 @@ biblios: > marc_type: marc21 > sort: 1 > suggestible: '' >- type: '' >+ type: 'callnumber' > cn-suffix: > label: cn-suffix > mappings: >diff --git a/installer/data/mysql/atomicupdate/bug_29632.pl b/installer/data/mysql/atomicupdate/bug_29632.pl >new file mode 100755 >index 0000000000..8b745f58e5 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_29632.pl >@@ -0,0 +1,15 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "29632 ", >+ description => "Add callnumber type to allow sorting", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ $dbh->do(q{ >+ ALTER TABLE `search_field` MODIFY COLUMN `type` >+ enum('','string','date','number','boolean','sum','isbn','stdno','year','callnumber') NOT NULL >+ }); >+ say $out "Add callnumber to search_field type enum"; >+ }, >+}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >index 05f3da43d2..c120a76ad1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >@@ -219,6 +219,11 @@ a.add, a.delete { > [% ELSE %] > <option value="stdno">Std. Number</option> > [% END %] >+ [% IF search_field.type == "callnumber" %] >+ <option value="callnumber" selected="selected">Call Number</option> >+ [% ELSE %] >+ <option value="callnumber">Call Number</option> >+ [% END %] > </select> > </td> > <td data-order="[% search_field.weight | html %]"> >-- >2.30.2
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 29632
:
136682
|
136754
|
137182
|
137539
|
137605
|
137606
|
137823
|
138611
|
139827