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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +4 lines)
Lines 352-358 sub build_query_compat { Link Here
352
        $query_cgi .= 'idx=' . uri_escape_utf8( $index // '' ) . '&q=' . uri_escape_utf8($oand);
352
        $query_cgi .= 'idx=' . uri_escape_utf8( $index // '' ) . '&q=' . uri_escape_utf8($oand);
353
        $query_cgi .= '&op=' . uri_escape_utf8($otor) if $otor;
353
        $query_cgi .= '&op=' . uri_escape_utf8($otor) if $otor;
354
    }
354
    }
355
    $query_cgi .= '&scan=1' if ($scan);
355
    $query_cgi .= '&scan=1'                    if ($scan);
356
    $query_cgi .= '&weight_search=1'           if ( $params->{weighted_fields} );
357
    $query_cgi .= '&weight_search_submitted=1' if ( $params->{weight_search_submitted} );
358
    $query_cgi .= '&whole_record=1'            if ( $params->{whole_record} );
356
359
357
    my $simple_query;
360
    my $simple_query;
358
    $simple_query = $operands->[0] if @$operands == 1;
361
    $simple_query = $operands->[0] if @$operands == 1;
(-)a/catalogue/search.pl (-7 / +21 lines)
Lines 435-445 for ( my $ii = 0 ; $ii < @operands ; ++$ii ) { Link Here
435
435
436
# Params that can only have one value
436
# Params that can only have one value
437
my $scan             = $params->{'scan'};
437
my $scan             = $params->{'scan'};
438
my $count            = C4::Context->preference('numSearchResults')         || 20;
438
my $count            = C4::Context->preference('numSearchResults') || 20;
439
my $results_per_page = $params->{'count'}                                  || $count;
439
my $results_per_page = $params->{'count'}                          || $count;
440
my $offset           = $params->{'offset'}                                 || 0;
440
my $offset           = $params->{'offset'}                         || 0;
441
my $whole_record     = $params->{'whole_record'}                           || 0;
441
my $whole_record     = $params->{'whole_record'}                   || 0;
442
my $weight_search    = $params->{'advsearch'} ? $params->{'weight_search'} || 0 : 1;
442
my $weight_search    = $params->{'weight_search_submitted'}
443
    ? ( $params->{'weight_search'} ? 1 : 0 )    # Form was submitted, use actual checkbox value
444
    : 0;                                        # Form not submitted or no weight_search context
443
$offset = 0 if $offset < 0;
445
$offset = 0 if $offset < 0;
444
446
445
# Define some global variables
447
# Define some global variables
Lines 461-467 for ( my $i = 0 ; $i < @operands ; $i++ ) { Link Here
461
    )
463
    )
462
    = $builder->build_query_compat(
464
    = $builder->build_query_compat(
463
    \@operators, \@operands, \@indexes, \@limits,
465
    \@operators, \@operands, \@indexes, \@limits,
464
    \@sort_by,   $scan,      $lang, { weighted_fields => $weight_search, whole_record => $whole_record }
466
    \@sort_by,
467
    $scan, $lang,
468
    {
469
        weighted_fields         => $weight_search,
470
        whole_record            => $whole_record,
471
        weight_search_submitted => $params->{'weight_search_submitted'}
472
    }
465
    );
473
    );
466
474
467
$template->param( search_query => $query ) if C4::Context->preference('DumpSearchQueryTemplate');
475
$template->param( search_query => $query ) if C4::Context->preference('DumpSearchQueryTemplate');
Lines 558-564 if ( $hits == 0 && $basic_search ) { Link Here
558
        )
566
        )
559
        = $builder->build_query_compat(
567
        = $builder->build_query_compat(
560
        \@operators, \@operands, \@indexes, \@limits,
568
        \@operators, \@operands, \@indexes, \@limits,
561
        \@sort_by,   $scan,      $lang, { weighted_fields => $weight_search, whole_record => $whole_record }
569
        \@sort_by,
570
        $scan, $lang,
571
        {
572
            weighted_fields         => $weight_search,
573
            whole_record            => $whole_record,
574
            weight_search_submitted => $params->{'weight_search_submitted'}
575
        }
562
        );
576
        );
563
    my $quoted_results_hashref;
577
    my $quoted_results_hashref;
564
    eval {
578
    eval {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (+2 lines)
Lines 156-165 Link Here
156
                                <label><input type="checkbox" name="whole_record" /> Search entire MARC record</label>
156
                                <label><input type="checkbox" name="whole_record" /> Search entire MARC record</label>
157
                            [% END %]
157
                            [% END %]
158
                            <span id="weight_search">
158
                            <span id="weight_search">
159
                                <input type="hidden" name="weight_search_submitted" value="1" />
159
                                <label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label>
160
                                <label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label>
160
                            </span>
161
                            </span>
161
                        </p>
162
                        </p>
162
                    [% ELSE %]
163
                    [% ELSE %]
164
                        <input type="hidden" name="weight_search_submitted" value="1" />
163
                        <input type="hidden" name="weight_search" value="1" />
165
                        <input type="hidden" name="weight_search" value="1" />
164
                    [% END %]
166
                    [% END %]
165
                [% END %]
167
                [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt (+2 lines)
Lines 151-156 Link Here
151
                                [% IF ( expanded_options ) %]
151
                                [% IF ( expanded_options ) %]
152
                                    [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
152
                                    [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
153
                                        <div id="weight_search">
153
                                        <div id="weight_search">
154
                                            <input type="hidden" name="weight_search_submitted" value="1" />
154
                                            <label>
155
                                            <label>
155
                                                <input type="checkbox" name="weight_search" checked="checked" />
156
                                                <input type="checkbox" name="weight_search" checked="checked" />
156
                                                Apply field weights to search
157
                                                Apply field weights to search
Lines 158-163 Link Here
158
                                        </div>
159
                                        </div>
159
                                    [% END %]
160
                                    [% END %]
160
                                [% ELSE %]
161
                                [% ELSE %]
162
                                    <input type="hidden" name="weight_search_submitted" value="1" />
161
                                    <input type="hidden" name="weight_search" value="1" />
163
                                    <input type="hidden" name="weight_search" value="1" />
162
                                [% END %]
164
                                [% END %]
163
                                [% IF Koha.Preference('IncludeSeeFromInSearches') %]
165
                                [% IF Koha.Preference('IncludeSeeFromInSearches') %]
(-)a/opac/opac-search.pl (-8 / +11 lines)
Lines 494-500 $offset = 0 if $offset < 0; Link Here
494
my $page = $cgi->param('page') || 1;
494
my $page = $cgi->param('page') || 1;
495
$offset = ( $page - 1 ) * $results_per_page if $page > 1;
495
$offset = ( $page - 1 ) * $results_per_page if $page > 1;
496
my $hits;
496
my $hits;
497
my $weight_search = $cgi->param('advsearch') ? $cgi->param('weight_search') || 0 : 1;
497
my $weight_search = $cgi->param('weight_search_submitted')
498
    ? ( $cgi->param('weight_search') ? 1 : 0 )    # Form was submitted, use actual checkbox value
499
    : 0;                                          # Form not submitted or no weight_search context
498
500
499
# Define some global variables
501
# Define some global variables
500
my ( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, $limit_desc, $query_type );
502
my ( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, $limit_desc, $query_type );
Lines 523-531 if ( C4::Context->preference('OpacSuppression') ) { Link Here
523
    0,
525
    0,
524
    $lang,
526
    $lang,
525
    {
527
    {
526
        suppress        => $suppress,
528
        suppress                => $suppress,
527
        is_opac         => 1,
529
        is_opac                 => 1,
528
        weighted_fields => $weight_search
530
        weighted_fields         => $weight_search,
531
        weight_search_submitted => $cgi->param('weight_search_submitted')
529
    }
532
    }
530
    );
533
    );
531
534
Lines 644-652 for ( my $i = 0 ; $i < @servers ; $i++ ) { Link Here
644
                0,
647
                0,
645
                $lang,
648
                $lang,
646
                {
649
                {
647
                    suppress        => $suppress,
650
                    suppress                => $suppress,
648
                    is_opac         => 1,
651
                    is_opac                 => 1,
649
                    weighted_fields => $weight_search
652
                    weighted_fields         => $weight_search,
653
                    weight_search_submitted => $cgi->param('weight_search_submitted')
650
                }
654
                }
651
                );
655
                );
652
            my $quoted_results_hashref;
656
            my $quoted_results_hashref;
653
- 

Return to bug 40966