Bugzilla – Attachment 95390 Details for
Bug 23089
Elasticsearch - cannot sort on non-text fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23089: [19.05 and earlier] Use integer field directly for sorting
Bug-23089-1905-and-earlier-Use-integer-field-direc.patch (text/plain), 2.40 KB, created by
Nick Clemens (kidclamp)
on 2019-11-13 14:31:57 UTC
(
hide
)
Description:
Bug 23089: [19.05 and earlier] Use integer field directly for sorting
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-11-13 14:31:57 UTC
Size:
2.40 KB
patch
obsolete
>From 5d013068f68d90acbb49cf0a1c4926ceb5b3432b Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 13 Nov 2019 14:31:39 +0000 >Subject: [PATCH] Bug 23089: [19.05 and earlier] Use integer field directly for > sorting > >--- > Koha/SearchEngine/Elasticsearch.pm | 2 +- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 8 ++++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 3b2b4ee08a..64ed46194b 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -228,7 +228,7 @@ sub get_elasticsearch_mappings { > # Sort is a bit special as it can be true, false, undef. > # We care about "true" or "undef", > # "undef" means to do the default thing, which is make it sortable. >- if (!defined $sort || $sort) { >+ if (!defined $sort || $sort && $es_type ne 'integer') { > $mappings->{data}{properties}{ $name . '__sort' } = _get_elasticsearch_field_config('sort', $es_type); > $sort_fields{$self->index}{$name} = 1; > } >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 7f0db644ae..63b9dbce7b 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -912,16 +912,16 @@ sub _sort_field { > my ($self, $f) = @_; > > my $mappings = $self->get_elasticsearch_mappings(); >- my $textField = defined $mappings->{data}{properties}{$f}{type} && $mappings->{data}{properties}{$f}{type} eq 'text'; >+ 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'; >+ $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 $textField; >+ $f .= '.phrase' if $fieldType eq 'text'; > } else { > # We need to add '.raw' to text fields without a sort field, > # otherwise it'll sort based on the tokenised form. >- $f .= '.raw' if $textField; >+ $f .= '.raw' if $fieldType eq 'text'; > } > return $f; > } >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23089
:
90451
|
93982
|
93983
|
94617
|
94618
|
94653
|
94656
|
94944
|
94945
|
94946
| 95390 |
96423