Bugzilla – Attachment 94945 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: Fix sorting on sum and regular fields
Bug-23089-Fix-sorting-on-sum-and-regular-fields.patch (text/plain), 2.69 KB, created by
Martin Renvoize (ashimema)
on 2019-11-01 10:46:42 UTC
(
hide
)
Description:
Bug 23089: Fix sorting on sum and regular fields
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-11-01 10:46:42 UTC
Size:
2.69 KB
patch
obsolete
>From 1d2ecb847a196b10eb9b56a2d86d07d5623b34d5 Mon Sep 17 00:00:00 2001 >From: Nick <nick@bywatersolutions.com> >Date: Thu, 10 Oct 2019 16:06:08 +0000 >Subject: [PATCH] Bug 23089: Fix sorting on sum and regular fields > >As of bug 20589 we no longer analyze sort fields and so we no longer need to append ".phrase" >to our sort in searches. > >Additionally, sort fields based on 'sum' should also use sum in building the value to sort on > >To test: >0 - Be using ES >1 - Find the most circulated item in your collection >2 - Search for '*' >3 - Sort by popularity DESC >4 - Note that item is not first >5 - Try to sort by anything but relevancy, it fails >6 - Apply patch >7 - Redo searches and sorts >8 - Things should now work as expected > >Signed-off-by: Ere Maijala <ere.maijala@helsinki.fi> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/SearchEngine/Elasticsearch.pm | 1 + > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 3 --- > admin/searchengine/elasticsearch/field_config.yaml | 1 + > 3 files changed, 2 insertions(+), 3 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index f91f16c10b..3d932b6dce 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -831,6 +831,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 b418739cdf..28c9297df4 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -992,9 +992,6 @@ sub _sort_field { > my $textField = defined $mappings->{data}{properties}{$f}{type} && $mappings->{data}{properties}{$f}{type} eq 'text'; > if (!defined $self->sort_fields()->{$f} || $self->sort_fields()->{$f}) { > $f .= '__sort'; >- # We need to add '.phrase' to text fields, otherwise it'll sort >- # based on the tokenised form. >- $f .= '.phrase' if $textField; > } 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 3494da45cf..e48cde7f57 100644 >--- a/admin/searchengine/elasticsearch/field_config.yaml >+++ b/admin/searchengine/elasticsearch/field_config.yaml >@@ -65,3 +65,4 @@ sort: > default: > type: icu_collation_keyword > index: false >+ numeric: true >-- >2.20.1
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