From 286e1709f917f9a8156893056bf91bb6c347c479 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 12 Nov 2019 17:15:14 +0100 Subject: [PATCH] Bug 23204: (follow-up) also sort by marc field Test plan : Launching script several times and see that marc field is alway ordered increasing --- Koha/SearchEngine/Elasticsearch.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index b5dedaad4b..e696a8cee3 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -260,10 +260,17 @@ sub raw_elasticsearch_mappings { my $mappings = {}; while ( my $search_field = $search_fields->next ) { - my $marc_to_fields = $schema->resultset('SearchMarcToField')->search( { search_field_id => $search_field->id } ); + my $marc_to_fields = $schema->resultset('SearchMarcToField')->search( + { search_field_id => $search_field->id }, + { + join => 'search_marc_map', + order_by => { -asc => 'search_marc_map.marc_field' } + } + ); while ( my $marc_to_field = $marc_to_fields->next ) { - my $marc_map = Koha::SearchMarcMaps->find( $marc_to_field->search_marc_map_id ); + + my $marc_map = $marc_to_field->search_marc_map; next if $marc_type && $marc_map->marc_type ne $marc_type; -- 2.24.0