diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index ad339ae7e4..c55810c2b1 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -392,13 +392,17 @@ sub _build_field_match_boost_query { my $indexes = $params->{indexes}; my $operands = $params->{operands}; + my $boost_amount = C4::Context->preference('ElasticsearchBoostFieldMatchAmount'); my @boost_query; + my $built_boost; my $ea = each_array( @$operands, @$indexes ); while ( my ( $operand, $index ) = $ea->() ) { next unless $operand; $index = $index->{field} if ref $index eq 'HASH'; $index = 'title-cover' if ( !$index || $index eq 'kw' || $index eq 'ti' || $index eq 'title' ); - push @boost_query, { match => { $index => { query => $operand } } }; + $built_boost = { match => { $index => { query => $operand } } }; + $built_boost->{match}->{$index}->{boost} = $boost_amount if $boost_amount; + push @boost_query, $built_boost; } return \@boost_query; } diff --git a/installer/data/mysql/atomicupdate/bug_40853.pl b/installer/data/mysql/atomicupdate/bug_40853.pl new file mode 100755 index 0000000000..9327e677b4 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_40853.pl @@ -0,0 +1,21 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "40853", + description => + "Add ElasticsearchBoostFieldMatchAmount to allow for increasing the weight of the additional field boost search", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value` ) VALUES + ('ElasticsearchBoostFieldMatchAmount', '0' ) + } + ); + + say $out "Added new system preference 'ElasticsearchBoostFieldMatchAmount'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index d321bf1213..13faac930f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -1,3 +1,4 @@ +<<<<<<< HEAD INSERT INTO systempreferences ( `variable`, `value` ) VALUES ('1PageOrderPDFText', 'Order number must appear on all related correspondence, shipping papers and invoices. Notify us immediately if \n you are unable to supply item(s).'), ('AccessControlAllowOrigin', ''), @@ -240,6 +241,7 @@ INSERT INTO systempreferences ( `variable`, `value` ) VALUES ('EdifactLSL', 'ccode'), ('EdifactLSQ', 'location'), ('ElasticsearchBoostFieldMatch', '0'), +('ElasticsearchBoostFieldMatchAmount', '0'), ('ElasticsearchCrossFields', '1'), ('ElasticsearchIndexStatus_authorities', '0'), ('ElasticsearchIndexStatus_biblios', '0'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 99c045d696..84c718d7b0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -101,7 +101,9 @@ Searching: choices: 1: Enable 0: Disable - - "adding a second 'match' field search to the ES query to boost relevancy. Keyword and title fields will be boosted with title-cover, other fields will boost directly." + - "adding a second 'match' field search to the ES query to boost relevancy by" + - pref: ElasticsearchBoostFieldMatchAmount + - "Keyword and title fields will be boosted with title-cover, other fields will boost directly." - "This will not boost CCL style searches, only standard or advanced searches." - - pref: SavedSearchFilters