|
Lines 200-217
sub build_query {
Link Here
|
| 200 |
if ($options{whole_record}) { |
200 |
if ($options{whole_record}) { |
| 201 |
push @$fields, 'marc_data_array.*'; |
201 |
push @$fields, 'marc_data_array.*'; |
| 202 |
} |
202 |
} |
| 203 |
$res->{query} = { |
203 |
my $query_string = { |
| 204 |
query_string => { |
|
|
| 205 |
query => $query, |
204 |
query => $query, |
| 206 |
fuzziness => $fuzzy_enabled ? 'auto' : '0', |
205 |
fuzziness => $fuzzy_enabled ? 'auto' : '0', |
| 207 |
default_operator => 'AND', |
206 |
default_operator => 'AND', |
| 208 |
fields => $fields, |
207 |
fields => $fields, |
| 209 |
lenient => JSON::true, |
208 |
lenient => JSON::true, |
| 210 |
analyze_wildcard => JSON::true, |
209 |
analyze_wildcard => JSON::true, |
|
|
210 |
}; |
| 211 |
$query_string->{type} = 'cross_fields' if C4::Context->preference('ElasticsearchCrossFields'); |
| 212 |
|
| 213 |
$res->{query} = { |
| 214 |
bool => { |
| 215 |
must => [ |
| 216 |
{query_string => $query_string} |
| 217 |
] |
| 211 |
} |
218 |
} |
| 212 |
}; |
219 |
}; |
| 213 |
$res->{query}->{query_string}->{type} = 'cross_fields' if C4::Context->preference('ElasticsearchCrossFields'); |
|
|
| 214 |
|
220 |
|
|
|
221 |
$res->{query}->{bool}->{should} = [ {match => { 'title-cover' => { query => $options{simple_query} } }}] if $options{simple_query}; |
| 215 |
if ( $options{sort} ) { |
222 |
if ( $options{sort} ) { |
| 216 |
foreach my $sort ( @{ $options{sort} } ) { |
223 |
foreach my $sort ( @{ $options{sort} } ) { |
| 217 |
my ( $f, $d ) = @$sort{qw/ field direction /}; |
224 |
my ( $f, $d ) = @$sort{qw/ field direction /}; |
|
Lines 262-267
sub build_query_compat {
Link Here
|
| 262 |
$lang, $params ) |
269 |
$lang, $params ) |
| 263 |
= @_; |
270 |
= @_; |
| 264 |
|
271 |
|
|
|
272 |
warn Data::Dumper::Dumper("rat", $operators," rand", $operands," ind", $indexes); |
| 273 |
my $simple_query; |
| 274 |
$simple_query = $operands->[0] if ( scalar @{$operands} == 1 && $operators && $indexes && !@{$operators} && !@{$indexes} ); |
| 265 |
my $query; |
275 |
my $query; |
| 266 |
my $query_str = ''; |
276 |
my $query_str = ''; |
| 267 |
my $search_param_query_str = ''; |
277 |
my $search_param_query_str = ''; |
|
Lines 314-319
sub build_query_compat {
Link Here
|
| 314 |
$options{is_opac} = $params->{is_opac}; |
324 |
$options{is_opac} = $params->{is_opac}; |
| 315 |
$options{weighted_fields} = $params->{weighted_fields}; |
325 |
$options{weighted_fields} = $params->{weighted_fields}; |
| 316 |
$options{whole_record} = $params->{whole_record}; |
326 |
$options{whole_record} = $params->{whole_record}; |
|
|
327 |
$options{simple_query} = $simple_query; |
| 317 |
$query = $self->build_query( $query_str, %options ); |
328 |
$query = $self->build_query( $query_str, %options ); |
| 318 |
} |
329 |
} |
| 319 |
|
330 |
|
| 320 |
- |
|
|