From 7ca057d03db509c3aba242686d8dbf4f75f52d40 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 8 Jan 2021 13:14:42 +0000 Subject: [PATCH] Bug 26051: We should sort callnumber based on cn-sort In zebra we sort by callnumber using 8007 cn-sort We should do the same in elasticsearch To test: 1 - Have Koha using Elasticsearch 2 - Perform a search 3 - Attempt to sort by callnumber 4 - Error in logs: No mapping found for [local-classification__sort] 5 - Apply patch 6 - Restart all 7 - Perform a search and sort by callnumber 8 - Success! Signed-off-by: Fridolin Somers Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit a52a0f80b890d70bb51c8629afbf4d81c2901491) Signed-off-by: Fridolin Somers (cherry picked from commit 726da171349310cdf5ef03a3d2876548b0b2f984) Signed-off-by: Andrew Fuerste-Henry --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 2 +- t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 81f6b13a9e..8e331d2fb8 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -589,7 +589,7 @@ sub _convert_sort_fields { my %sort_field_convert = ( acqdate => 'date-of-acquisition', author => 'author', - call_number => 'local-classification', + call_number => 'cn-sort', popularity => 'issues', relevance => undef, # default title => 'title', diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t index 07861c7f28..a66c039af2 100644 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t @@ -703,7 +703,7 @@ subtest "_convert_sort_fields() tests" => sub { is_deeply( \@sort_by, [ - { field => 'local-classification', direction => 'asc' }, + { field => 'cn-sort', direction => 'asc' }, { field => 'author', direction => 'desc' } ], 'sort fields should have been split correctly' @@ -714,7 +714,7 @@ subtest "_convert_sort_fields() tests" => sub { is_deeply( \@sort_by, [ - { field => 'local-classification', direction => 'asc' }, + { field => 'cn-sort', direction => 'asc' }, { field => 'author', direction => 'desc' } ], 'sort fields should have been split correctly' -- 2.39.5