From e578d0b36b9232ed1883f73692fac1b732cf7a85 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 25 Mar 2020 17:10:40 +0000 Subject: [PATCH] Bug 23204: Fix ordering of fields in exported file Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- Koha/SearchEngine/Elasticsearch.pm | 6 +++--- .../Bug_23204_change_search_marc_map_enum_order.perl | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_23204_change_search_marc_map_enum_order.perl diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index ce762a00ce..8ee939d2be 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -267,7 +267,7 @@ sub raw_elasticsearch_mappings { { search_field_id => $search_field->id }, { join => 'search_marc_map', - order_by => { -asc => 'search_marc_map.marc_field' } + order_by => { -asc => ['search_marc_map.marc_type','search_marc_map.marc_field'] } } ); @@ -279,8 +279,8 @@ sub raw_elasticsearch_mappings { $mappings->{ $marc_map->index_name }{ $search_field->name }{label} = $search_field->label; $mappings->{ $marc_map->index_name }{ $search_field->name }{type} = $search_field->type; - $mappings->{ $marc_map->index_name }{ $search_field->name }{facet_order} = $search_field->facet_order; - $mappings->{ $marc_map->index_name }{ $search_field->name }{weight} = $search_field->weight || undef; + $mappings->{ $marc_map->index_name }{ $search_field->name }{facet_order} = $search_field->facet_order if defined $search_field->facet_order; + $mappings->{ $marc_map->index_name }{ $search_field->name }{weight} = $search_field->weight if defined $search_field->weight; push (@{ $mappings->{ $marc_map->index_name }{ $search_field->name }{mappings} }, { diff --git a/installer/data/mysql/atomicupdate/Bug_23204_change_search_marc_map_enum_order.perl b/installer/data/mysql/atomicupdate/Bug_23204_change_search_marc_map_enum_order.perl new file mode 100644 index 0000000000..c5493b4d77 --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug_23204_change_search_marc_map_enum_order.perl @@ -0,0 +1,7 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + ALTER TABLE search_marc_map CHANGE marc_type `marc_type` enum('marc21','normarc','unimarc') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'what MARC type this map is for'; + }); + NewVersion( $DBversion, 23204, "Change enum order for marc_type in search_marc_map to fix sorting"); +} -- 2.39.5