View | Details | Raw Unified | Return to bug 40853
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +5 lines)
Lines 389-401 sub _build_field_match_boost_query { Link Here
389
    my $indexes  = $params->{indexes};
389
    my $indexes  = $params->{indexes};
390
    my $operands = $params->{operands};
390
    my $operands = $params->{operands};
391
391
392
    my $boost_amount = C4::Context->preference('ElasticsearchBoostFieldMatchAmount');
392
    my @boost_query;
393
    my @boost_query;
394
    my $built_boost;
393
    my $ea = each_array( @$operands, @$indexes );
395
    my $ea = each_array( @$operands, @$indexes );
394
    while ( my ( $operand, $index ) = $ea->() ) {
396
    while ( my ( $operand, $index ) = $ea->() ) {
395
        next unless $operand;
397
        next unless $operand;
396
        $index = $index->{field} if ref $index eq 'HASH';
398
        $index = $index->{field} if ref $index eq 'HASH';
397
        $index = 'title-cover'   if ( !$index || $index eq 'kw' || $index eq 'ti' || $index eq 'title' );
399
        $index = 'title-cover'   if ( !$index || $index eq 'kw' || $index eq 'ti' || $index eq 'title' );
398
        push @boost_query, { match => { $index => { query => $operand } } };
400
        $built_boost = { match => { $index => { query => $operand } } };
401
        $built_boost->{match}->{$index}->{boost} = $boost_amount if $boost_amount;
402
        push @boost_query, $built_boost;
399
    }
403
    }
400
    return \@boost_query;
404
    return \@boost_query;
401
}
405
}
(-)a/installer/data/mysql/atomicupdate/bug_40853.pl (+20 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "BUG_NUMBER",
6
    description => "A single line description",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        $dbh->do(
12
            q{
13
            INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14
            ('ElasticsearchBoostFieldMatchAmount', '0', NULL, 'A numeric rank for the boost of field matches', 'Integer')
15
        }
16
        );
17
18
        say $out "Added new system preference 'ElasticsearchBoostFieldMatchAmount'";
19
    },
20
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 237-242 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
237
('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'),
237
('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'),
238
('EdifactLSQ', 'location', 'location|ccode', 'Map EDI sequence code (GIR+LSQ) to Koha Item field', 'Choice'),
238
('EdifactLSQ', 'location', 'location|ccode', 'Map EDI sequence code (GIR+LSQ) to Koha Item field', 'Choice'),
239
('ElasticsearchBoostFieldMatch', '0', NULL, 'Add a "match" query to es when searching, will follow indexes chosen in advanced search, or use title-cover for generic keyword or title index search', 'YesNo'),
239
('ElasticsearchBoostFieldMatch', '0', NULL, 'Add a "match" query to es when searching, will follow indexes chosen in advanced search, or use title-cover for generic keyword or title index search', 'YesNo'),
240
('ElasticsearchBoostFieldMatchAmount', '1', NULL, 'A numeric rank for the boost of field matches', 'Integer'),
240
('ElasticsearchCrossFields', '1', '', 'Enable "cross_fields" option for searches using Elastic search.', 'YesNo'),
241
('ElasticsearchCrossFields', '1', '', 'Enable "cross_fields" option for searches using Elastic search.', 'YesNo'),
241
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
242
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
242
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
243
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (-2 / +3 lines)
Lines 101-107 Searching: Link Here
101
              choices:
101
              choices:
102
                  1: Enable
102
                  1: Enable
103
                  0: Disable
103
                  0: Disable
104
            - "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."
104
            - "adding a second 'match' field search to the ES query to boost relevancy by"
105
            - pref: ElasticsearchBoostFieldMatchAmount
106
            - "Keyword and title fields will be boosted with title-cover, other fields will boost directly."
105
            - "This will not boost CCL style searches, only standard or advanced searches."
107
            - "This will not boost CCL style searches, only standard or advanced searches."
106
        -
108
        -
107
            - pref: SavedSearchFilters
109
            - pref: SavedSearchFilters
108
- 

Return to bug 40853