Bugzilla – Attachment 108391 Details for
Bug 23875
Elasticsearch - When sorting by score we should provide a tiebreaker
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23875: Explicitly srt searches by score and provide local-number as tie breaker
Bug-23875-Explicitly-srt-searches-by-score-and-pro.patch (text/plain), 3.06 KB, created by
Nick Clemens (kidclamp)
on 2020-08-17 11:14:53 UTC
(
hide
)
Description:
Bug 23875: Explicitly srt searches by score and provide local-number as tie breaker
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-08-17 11:14:53 UTC
Size:
3.06 KB
patch
obsolete
>From 372c9e48ce039afa630a583822b02b07bf7adc89 Mon Sep 17 00:00:00 2001 >From: Nick <nick@bywatersolutions.com> >Date: Tue, 22 Oct 2019 14:38:58 +0000 >Subject: [PATCH] Bug 23875: Explicitly srt searches by score and provide > local-number as tie breaker > >To test: > 1 - Set search engine to ES > 2 - Search the catalog for "*" > 3 - Note results > 4 - Edit first result > 5 - Repeat search, results are reordered > 6 - Apply patch > 7 - Search for "*" > 8 - Highest biblionumbers are returned first > 9 - Edit first result, repeat search >10 - Order does not change >11 - Confirm sorting by author, title, etc passes the same trials > >Signed-off-by: Ere Maijala <ere.maijala@helsinki.fi> >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 6 +++++ > .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 28 ++++++++++++++++++++-- > 2 files changed, 32 insertions(+), 2 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 8f3aea9445..4bc33dd145 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -114,6 +114,12 @@ sub build_query { > push @{ $res->{sort} }, { $f => { order => $d } }; > } > } >+ # If not sorting by anything explicitly search by score >+ if (!defined $res->{sort}){ >+ push @{ $res->{sort} }, { _score => { order => 'desc' } }; >+ } >+ # Add a tie breaker in case of equally relevant records >+ push @{ $res->{sort} }, { 'local-number.raw' => { order => 'desc' } }; > > # See _convert_facets in Search.pm for how these get turned into > # things that Koha can use. >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index 1266da5ffe..cb9d98e0f7 100644 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -216,7 +216,7 @@ subtest 'build_authorities_query_compat() tests' => sub { > }; > > subtest 'build_query tests' => sub { >- plan tests => 53; >+ plan tests => 54; > > my $qb; > >@@ -238,11 +238,35 @@ subtest 'build_query tests' => sub { > 'title__sort' => { > 'order' => 'asc' > } >- } >+ }, >+ { >+ 'local-number.raw' => { >+ 'order' => 'desc' >+ } >+ } > ], > "sort parameter properly formed" > ); > >+ $query = $qb->build_query('test', () ); >+ >+ is_deeply( >+ $query->{sort}, >+ [ >+ { >+ '_score' => { >+ 'order' => 'desc' >+ } >+ }, >+ { >+ 'local-number.raw' => { >+ 'order' => 'desc' >+ } >+ } >+ ], >+ "sort parameter properly formed if no sort passed" >+ ); >+ > t::lib::Mocks::mock_preference('FacetMaxCount','37'); > t::lib::Mocks::mock_preference('DisplayLibraryFacets','both'); > $query = $qb->build_query('test', %options); >-- >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 23875
:
94579
|
94712
|
108391
|
174227