diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 0a14e8d0b7..e7c1e1e903 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -699,6 +699,7 @@ sub _get_marc_mapping_rules { if ($type eq 'sum') { push @{$rules->{sum}}, $name; + push @{$rules->{sum}}, $name."__sort" if $sort; } elsif ($type eq 'isbn') { push @{$rules->{isbn}}, $name; diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index ee8cb6c6c8..8388806269 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -909,10 +909,7 @@ sub _sort_field { my $mappings = $self->get_elasticsearch_mappings(); my $fieldType = defined $mappings->{data}{properties}{$f}{type} ? $mappings->{data}{properties}{$f}{type} : undef; if (!defined $self->sort_fields()->{$f} || $self->sort_fields()->{$f}) { - $f .= '__sort' unless $fieldType eq 'integer'; - # We need to add '.phrase' to text fields, otherwise it'll sort - # based on the tokenised form. - $f .= '.phrase' if $fieldType eq 'text'; + $f .= '__sort'; } else { # We need to add '.raw' to text fields without a sort field, # otherwise it'll sort based on the tokenised form. diff --git a/admin/searchengine/elasticsearch/field_config.yaml b/admin/searchengine/elasticsearch/field_config.yaml index 0baddf3a02..495224a5a7 100644 --- a/admin/searchengine/elasticsearch/field_config.yaml +++ b/admin/searchengine/elasticsearch/field_config.yaml @@ -64,9 +64,6 @@ suggestible: # Sort sort: default: - type: text - analyzer: analyser_phrase - search_analyzer: analyser_phrase - fields: - phrase: - type: keyword + type: icu_collation_keyword + index: false + numeric: true