Bugzilla – Attachment 185441 Details for
Bug 40658
When sorting by local-number we should use the sort field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40658: Use local-number__sort and not local-number directly
Bug-40658-Use-local-numbersort-and-not-local-numbe.patch (text/plain), 3.13 KB, created by
Nick Clemens (kidclamp)
on 2025-08-15 12:18:24 UTC
(
hide
)
Description:
Bug 40658: Use local-number__sort and not local-number directly
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-08-15 12:18:24 UTC
Size:
3.13 KB
patch
obsolete
>From 9631c12a7037794f68da216649263226d1f4b15a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 15 Aug 2025 12:12:22 +0000 >Subject: [PATCH] Bug 40658: Use local-number__sort and not local-number > directly > >This patch makes sure we inject the __sort form of local-number, rather >than the field directly - this ensurs searching works even if mappings mayu >be different and local-number itself is not numeric > >To test: >1 - Edit mappings.yaml and set local-number from 'number' to 'string' > NOTE: There are two copies of local-number - one in auth and one in biblio - the latter is the important one here >2 - perl misc/search_tools/rebuild_elasticsearch.pl -r -v >3 - Confirm in staff interface Admin -> Search Engine Configuration that local-number is now a string >4 - Search and get an error > Error: Unable to perform your search. Please try again. > In the logs: >[illegal_argument_exception] Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [local-number] in order to load field data by uninverting the inverted index. Note that this can use significant memory. >5 - Apply patch, restart all >6 - Search again >7 - Success! >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 2 +- > .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 431f9f2e114..f02ebaa9941 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -235,7 +235,7 @@ sub build_query { > } > > # Add a tie breaker in case of equally relevant records >- push @{ $res->{sort} }, { 'local-number' => { order => 'desc' } }; >+ push @{ $res->{sort} }, { 'local-number__sort' => { order => 'desc' } }; > > unless ( $options{skip_facets} ) { > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index a8310a74117..08aabff3c4f 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -269,7 +269,7 @@ subtest 'build_query tests' => sub { > > is_deeply( > $query->{sort}, >- [ { 'title__sort' => { 'order' => 'asc' } }, { 'local-number' => { 'order' => 'desc' } } ], >+ [ { 'title__sort' => { 'order' => 'asc' } }, { 'local-number__sort' => { 'order' => 'desc' } } ], > "sort parameter properly formed" > ); > >@@ -296,8 +296,8 @@ subtest 'build_query tests' => sub { > is_deeply( > $query->{sort}, > [ >- { '_score' => { 'order' => 'desc' } }, >- { 'local-number' => { 'order' => 'desc' } } >+ { '_score' => { 'order' => 'desc' } }, >+ { 'local-number__sort' => { 'order' => 'desc' } } > ], > "sort parameter properly formed if no sort passed" > ); >-- >2.39.5
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 40658
: 185441 |
185447