Lines 137-142
our %index_field_convert = (
Link Here
|
137 |
); |
137 |
); |
138 |
my $field_name_pattern = '[\w\-]+'; |
138 |
my $field_name_pattern = '[\w\-]+'; |
139 |
my $multi_field_pattern = "(?:\\.$field_name_pattern)*"; |
139 |
my $multi_field_pattern = "(?:\\.$field_name_pattern)*"; |
|
|
140 |
my $es_advanced_searches = []; |
140 |
|
141 |
|
141 |
=head2 get_index_field_convert |
142 |
=head2 get_index_field_convert |
142 |
|
143 |
|
Lines 245-250
sub build_query {
Link Here
|
245 |
or $display_library_facets eq 'holding' ) { |
246 |
or $display_library_facets eq 'holding' ) { |
246 |
$res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } }; |
247 |
$res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } }; |
247 |
} |
248 |
} |
|
|
249 |
|
250 |
$res = _rebuild_to_es_advanced_query($res) if @$es_advanced_searches ; |
248 |
return $res; |
251 |
return $res; |
249 |
} |
252 |
} |
250 |
|
253 |
|
Lines 929-934
operand.
Link Here
|
929 |
|
932 |
|
930 |
sub _create_query_string { |
933 |
sub _create_query_string { |
931 |
my ( $self, @queries ) = @_; |
934 |
my ( $self, @queries ) = @_; |
|
|
935 |
foreach my $q (@queries) { |
936 |
if ($q->{field} && $q->{field} eq 'geolocation') { |
937 |
push(@$es_advanced_searches, $q); |
938 |
} |
939 |
} |
940 |
@queries = grep { $_->{field} ne 'geolocation' } @queries; |
932 |
|
941 |
|
933 |
map { |
942 |
map { |
934 |
my $otor = $_->{operator} ? $_->{operator} . ' ' : ''; |
943 |
my $otor = $_->{operator} ? $_->{operator} . ' ' : ''; |
Lines 1082-1088
sub _fix_limit_special_cases {
Link Here
|
1082 |
|
1091 |
|
1083 |
my @new_lim; |
1092 |
my @new_lim; |
1084 |
foreach my $l (@$limits) { |
1093 |
foreach my $l (@$limits) { |
1085 |
|
|
|
1086 |
# This is set up by opac-search.pl |
1094 |
# This is set up by opac-search.pl |
1087 |
if ( $l =~ /^yr,st-numeric,ge[=:]/ ) { |
1095 |
if ( $l =~ /^yr,st-numeric,ge[=:]/ ) { |
1088 |
my ( $start, $end ) = |
1096 |
my ( $start, $end ) = |
Lines 1335-1338
sub _search_fields {
Link Here
|
1335 |
} |
1343 |
} |
1336 |
} |
1344 |
} |
1337 |
|
1345 |
|
|
|
1346 |
sub _rebuild_to_es_advanced_query { |
1347 |
my ($res) = @_; |
1348 |
my $query_string = $res->{query}->{query_string}; |
1349 |
$query_string->{query} = '*' unless $query_string->{query}; |
1350 |
delete $res->{query}->{query_string}; |
1351 |
|
1352 |
my %filter; |
1353 |
for my $advanced_query (@$es_advanced_searches) { |
1354 |
if ( $advanced_query->{field} eq 'geolocation') { |
1355 |
my ($lat, $lon, $distance) = map { $_ =~ /:(.*)\*/ } split('\s+', $advanced_query->{operand}); |
1356 |
$filter{geo_distance} = { |
1357 |
distance => $distance, |
1358 |
geolocation => { |
1359 |
lat => $lat, |
1360 |
lon => $lon, |
1361 |
} |
1362 |
}; |
1363 |
} |
1364 |
else { |
1365 |
warn "unknown advanced ElasticSearch query: ".join(', ',%$advanced_query); |
1366 |
} |
1367 |
} |
1368 |
|
1369 |
$res->{query} = { |
1370 |
bool => { |
1371 |
must => { |
1372 |
query_string => $query_string |
1373 |
}, |
1374 |
filter => \%filter, |
1375 |
} |
1376 |
}; |
1377 |
|
1378 |
return $res; |
1379 |
} |
1380 |
|
1381 |
|
1338 |
1; |
1382 |
1; |