Bug 19563: (follow-up) Restore checking sort variable

This code seems a bit odd, $self->sort_fields()->{$name} is checking if
there is any mapping in ES for a field, so if one marc field in an index
is marked as sortable this will exists. We need to check the individual
marc field to see if it should be added to the sort index here.

If you apply the first patch, reindex, and view a record in es:
curl -XGET 'localhost:9200/koha_kohadev_biblios/data/19/?pretty' | grep
-A 10 author__sort

You will see that 245$c is included in the record without that
additional check

Apply this, reindex again, and that field should not be included

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2017-11-17 12:13:55 +00:00 committed by Jonathan Druart
parent db776c34d2
commit e1ba8d344d
1 changed files with 3 additions and 2 deletions

View File

@ -297,7 +297,6 @@ sub reset_elasticsearch_mappings {
# sort_fields isn't set, then it'll generate it.
sub sort_fields {
my $self = shift;
if (@_) {
$self->_sort_fields_accessor(@_);
return;
@ -348,7 +347,9 @@ sub get_fixer_rules {
push @rules, "sum('$name')";
}
if ($self->sort_fields()->{$name}) {
push @rules, "marc_map('$marc_field','${name}__sort.\$append', $options)";
if ($sort || !defined $sort) {
push @rules, "marc_map('$marc_field','${name}__sort.\$append', $options)";
}
}
}
);