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 226-234 sub build_query_compat { Link Here
226
        join( ' ', $self->_create_query_string(@search_params) ) || (),
228
        join( ' ', $self->_create_query_string(@search_params) ) || (),
227
        $self->_join_queries( $self->_convert_index_strings(@$limits) ) || () );
229
        $self->_join_queries( $self->_convert_index_strings(@$limits) ) || () );
228
230
231
    my @weights = $params->{weight};
232
    my @w_fields = $params->{w_fields};
233
    my @fields = '_all';
234
    if ( defined $weights[0] ) {
235
        for (my $i = 0 ; $i < (scalar @weights) ; $i++ ){
236
            push @fields, "$w_fields[$i]^$weights[$i]";
237
        }
238
    }
239
229
    # If there's no query on the left, let's remove the junk left behind
240
    # If there's no query on the left, let's remove the junk left behind
230
    $query_str =~ s/^ AND //;
241
    $query_str =~ s/^ AND //;
231
    my %options;
242
    my %options;
243
    $options{fields} = \@fields;
232
    $options{sort} = \@sort_params;
244
    $options{sort} = \@sort_params;
233
    $options{expanded_facet} = $params->{expanded_facet};
245
    $options{expanded_facet} = $params->{expanded_facet};
234
    my $query = $self->build_query( $query_str, %options );
246
    my $query = $self->build_query( $query_str, %options );
(-)a/catalogue/search.pl (-1 / +4 lines)
Lines 381-386 my @operators = map uri_unescape($_), $cgi->multi_param('op'); Link Here
381
# can be single or multiple parameters separated by comma: kw,right-Truncation 
381
# can be single or multiple parameters separated by comma: kw,right-Truncation 
382
my @indexes = map uri_unescape($_), $cgi->multi_param('idx');
382
my @indexes = map uri_unescape($_), $cgi->multi_param('idx');
383
383
384
my @w_fields = map $_, $cgi->multi_param('field');
385
my @weight = map $_, $cgi->multi_param('weight');
386
384
# if a simple index (only one)  display the index used in the top search box
387
# if a simple index (only one)  display the index used in the top search box
385
if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) {
388
if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) {
386
    my $idx = "ms_".$indexes[0];
389
    my $idx = "ms_".$indexes[0];
Lines 468-474 my $searcher = Koha::SearchEngine::Search->new( Link Here
468
    $query_type
471
    $query_type
469
  )
472
  )
470
  = $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits,
473
  = $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits,
471
    \@sort_by, $scan, $lang );
474
    \@sort_by, $scan, $lang, { w_fields => @w_fields, weight => @weight  } );
472
475
473
## parse the query_cgi string and put it into a form suitable for <input>s
476
## parse the query_cgi string and put it into a form suitable for <input>s
474
my @query_inputs;
477
my @query_inputs;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (-1 / +11 lines)
Lines 112-117 Link Here
112
<!-- /BOOLEAN SEARCH OPTIONS -->
112
<!-- /BOOLEAN SEARCH OPTIONS -->
113
113
114
</div>
114
</div>
115
116
<div>
117
    <fieldset>
118
        <select name="field">
119
            <option value='title'>Title</option>
120
            <option value='subject'>Subject</option>
121
        </select>
122
        <label for='weight'>Weight</label>
123
        <input name='weight' type='text' value="" />
124
    </fieldset>
125
</div>
115
<!-- MC-TYPE LIMITS -->
126
<!-- MC-TYPE LIMITS -->
116
    <div class="yui-g">
127
    <div class="yui-g">
117
      <div id="advsearches" class="toptabs">
128
      <div id="advsearches" class="toptabs">
118
- 

Return to bug 18316