From 0c9585333dcb0fe2082662c82d3f65823ab72c7c 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 Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- 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 850a4373d1..ce762a00ce 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -263,10 +263,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.39.5