Bugzilla – Attachment 187425 Details for
Bug 40853
ElasticsearchBoostFieldMatch - needs to boost results more
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40853: Unit tests
Bug-40853-Unit-tests.patch (text/plain), 2.43 KB, created by
Nick Clemens (kidclamp)
on 2025-10-03 19:35:59 UTC
(
hide
)
Description:
Bug 40853: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-10-03 19:35:59 UTC
Size:
2.43 KB
patch
obsolete
>From b303c607b55fabe746a6e8a629f9c92c5efd9815 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 3 Oct 2025 19:35:43 +0000 >Subject: [PATCH] Bug 40853: Unit tests > >--- > .../SearchEngine/Elasticsearch/QueryBuilder.t | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index a47dd32a3d4..485e59fd26f 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -1205,8 +1205,9 @@ subtest "_sort_field() tests" => sub { > }; > > subtest "_build_field_match_boost_query() tests" => sub { >- plan tests => 10; >+ plan tests => 11; > >+ t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatchAmount', '0' ); > my $qb; > > ok( >@@ -1269,6 +1270,18 @@ subtest "_build_field_match_boost_query() tests" => sub { > 'Title is not converted to title-cover' > ); > >+ t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatchAmount', '10' ); >+ $field_match_boost_query = $qb->_build_field_match_boost_query( { indexes => \@indexes, operands => \@operands } ); >+ is_deeply( >+ $field_match_boost_query, >+ [ >+ { match => { 'title-cover' => { boost => 10, query => 'turkey' } } }, >+ { match => { 'subject' => { boost => 10, query => 'gravy' } } }, >+ { match => { 'title-cover' => { boost => 10, query => 'mashed' } } }, >+ ], >+ 'Boost is added to fields as expected only when pref has a value' >+ ); >+ > t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '0' ); > t::lib::Mocks::mock_preference( 'QueryAutoTruncate', '1' ); > my ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] ); >@@ -1283,7 +1296,8 @@ subtest "_build_field_match_boost_query() tests" => sub { > 'No should query added for boosting' > ); > >- t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '1' ); >+ t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatch', '1' ); >+ t::lib::Mocks::mock_preference( 'ElasticsearchBoostFieldMatchAmount', '0' ); > ( undef, $query ) = $qb->build_query_compat( ['AND'], [ 'donald duck', 'disney' ], [ 'title', 'author' ] ); > is_deeply( > $query->{query}{bool}{should}, >-- >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 40853
:
187422
|
187425
|
187500
|
187501
|
187582