Bug 40853: Add ElasticsearchBoostFieldMatchAmount system preference
This adds a new system preference to control the amount of boost. The default of 0 will act as before this patch.
You can add any positive number, or a number between 0 and 1 for negative boost
To test:
1 - Add a record with
245 $a novel
2 - Add a record with
245 $a A novel : $b about things / $c by me
3 - Search for: novel
4 - Search for: a novel
5 - Apply patch, restart all
6 - Repeat searches, note exact titles are boosted
7 - Test with more titles as you are able
Signed-off-by: Jason Robb <jrobb@sekls.org>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
parent
06fa749960
commit
02fa01e146
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'";
|
||||
},
|
||||
};
|
||||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue