Lines 912-927
sub _sort_field {
Link Here
|
912 |
my ($self, $f) = @_; |
912 |
my ($self, $f) = @_; |
913 |
|
913 |
|
914 |
my $mappings = $self->get_elasticsearch_mappings(); |
914 |
my $mappings = $self->get_elasticsearch_mappings(); |
915 |
my $textField = defined $mappings->{data}{properties}{$f}{type} && $mappings->{data}{properties}{$f}{type} eq 'text'; |
915 |
my $fieldType = defined $mappings->{data}{properties}{$f}{type} ? $mappings->{data}{properties}{$f}{type} : undef; |
916 |
if (!defined $self->sort_fields()->{$f} || $self->sort_fields()->{$f}) { |
916 |
if (!defined $self->sort_fields()->{$f} || $self->sort_fields()->{$f}) { |
917 |
$f .= '__sort'; |
917 |
$f .= '__sort' unless $fieldType eq 'integer'; |
918 |
# We need to add '.phrase' to text fields, otherwise it'll sort |
918 |
# We need to add '.phrase' to text fields, otherwise it'll sort |
919 |
# based on the tokenised form. |
919 |
# based on the tokenised form. |
920 |
$f .= '.phrase' if $textField; |
920 |
$f .= '.phrase' if $fieldType eq 'text'; |
921 |
} else { |
921 |
} else { |
922 |
# We need to add '.raw' to text fields without a sort field, |
922 |
# We need to add '.raw' to text fields without a sort field, |
923 |
# otherwise it'll sort based on the tokenised form. |
923 |
# otherwise it'll sort based on the tokenised form. |
924 |
$f .= '.raw' if $textField; |
924 |
$f .= '.raw' if $fieldType eq 'text'; |
925 |
} |
925 |
} |
926 |
return $f; |
926 |
return $f; |
927 |
} |
927 |
} |
928 |
- |
|
|