From aa1649be0ce21427f5f94d4fc7f0a4b9165c267a 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 --- 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 d551ad93c1..7addc5313f 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -694,7 +694,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 100755 --- 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.20.1