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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (+12 lines)
Lines 92-97 sub build_query { Link Here
92
            default_operator => 'AND',
92
            default_operator => 'AND',
93
            default_field    => '_all',
93
            default_field    => '_all',
94
            lenient          => JSON::true,
94
            lenient          => JSON::true,
95
            fields           => $options{fields},
96
            use_dis_max      => JSON::true,
95
        }
97
        }
96
    };
98
    };
97
99
Lines 228-236 sub build_query_compat { Link Here
228
        join( ' ', $self->_create_query_string(@search_params) ) || (),
230
        join( ' ', $self->_create_query_string(@search_params) ) || (),
229
        $self->_join_queries( $self->_convert_index_strings(@$limits) ) || () );
231
        $self->_join_queries( $self->_convert_index_strings(@$limits) ) || () );
230
232
233
    my @weights = $params->{weight};
234
    my @w_fields = $params->{w_fields};
235
    my @fields = '_all';
236
    if ( defined $weights[0] ) {
237
        for (my $i = 0 ; $i < (scalar @weights) ; $i++ ){
238
            push @fields, "$w_fields[$i]^$weights[$i]";
239
        }
240
    }
241
231
    # If there's no query on the left, let's remove the junk left behind
242
    # If there's no query on the left, let's remove the junk left behind
232
    $query_str =~ s/^ AND //;
243
    $query_str =~ s/^ AND //;
233
    my %options;
244
    my %options;
245
    $options{fields} = \@fields;
234
    $options{sort} = \@sort_params;
246
    $options{sort} = \@sort_params;
235
    $options{expanded_facet} = $params->{expanded_facet};
247
    $options{expanded_facet} = $params->{expanded_facet};
236
    my $query = $self->build_query( $query_str, %options );
248
    my $query = $self->build_query( $query_str, %options );
(-)a/catalogue/search.pl (-1 / +4 lines)
Lines 379-384 my @operators = map uri_unescape($_), $cgi->multi_param('op'); Link Here
379
# can be single or multiple parameters separated by comma: kw,right-Truncation 
379
# can be single or multiple parameters separated by comma: kw,right-Truncation 
380
my @indexes = map uri_unescape($_), $cgi->multi_param('idx');
380
my @indexes = map uri_unescape($_), $cgi->multi_param('idx');
381
381
382
my @w_fields = map $_, $cgi->multi_param('field');
383
my @weight = map $_, $cgi->multi_param('weight');
384
382
# if a simple index (only one)  display the index used in the top search box
385
# if a simple index (only one)  display the index used in the top search box
383
if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) {
386
if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) {
384
    my $idx = "ms_".$indexes[0];
387
    my $idx = "ms_".$indexes[0];
Lines 467-473 my $searcher = Koha::SearchEngine::Search->new( Link Here
467
    $query_type
470
    $query_type
468
  )
471
  )
469
  = $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits,
472
  = $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits,
470
    \@sort_by, $scan, $lang );
473
    \@sort_by, $scan, $lang, { w_fields => @w_fields, weight => @weight  } );
471
474
472
## parse the query_cgi string and put it into a form suitable for <input>s
475
## parse the query_cgi string and put it into a form suitable for <input>s
473
my @query_inputs;
476
my @query_inputs;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (-1 / +11 lines)
Lines 96-101 Link Here
96
<!-- /BOOLEAN SEARCH OPTIONS -->
96
<!-- /BOOLEAN SEARCH OPTIONS -->
97
97
98
</div>
98
</div>
99
100
<div>
101
    <fieldset>
102
        <select name="field">
103
            <option value='title'>Title</option>
104
            <option value='subject'>Subject</option>
105
        </select>
106
        <label for='weight'>Weight</label>
107
        <input name='weight' type='text' value="" />
108
    </fieldset>
109
</div>
99
<!-- MC-TYPE LIMITS -->
110
<!-- MC-TYPE LIMITS -->
100
      <div id="advsearches" class="toptabs">
111
      <div id="advsearches" class="toptabs">
101
      <ul>
112
      <ul>
102
- 

Return to bug 18316