Lines 1418-1431
sub _rebuild_to_es_advanced_query {
Link Here
|
1418 |
my %filter; |
1418 |
my %filter; |
1419 |
for my $advanced_query (@$es_advanced_searches) { |
1419 |
for my $advanced_query (@$es_advanced_searches) { |
1420 |
if ( $advanced_query->{field} eq 'geolocation' ) { |
1420 |
if ( $advanced_query->{field} eq 'geolocation' ) { |
1421 |
my ( $lat, $lon, $distance ) = map { $_ =~ /:(.*)\*/ } split( '\s+', $advanced_query->{operand} ); |
1421 |
my %args = map { split ':' } map { s/\*$//r } split /\s+/, $advanced_query->{operand}; |
1422 |
$filter{geo_distance} = { |
1422 |
if ($args{lat} and $args{lng} and $args{distance}) { |
1423 |
distance => $distance, |
1423 |
$filter{geo_distance} = { |
1424 |
geolocation => { |
1424 |
distance => $args{distance}, |
1425 |
lat => $lat, |
1425 |
geolocation => { |
1426 |
lon => $lon, |
1426 |
lat => $args{lat}, |
1427 |
} |
1427 |
lon => $args{lng}, |
1428 |
}; |
1428 |
} |
|
|
1429 |
}; |
1430 |
} elsif ($args{boundingbox}) { |
1431 |
my ($top_left_lat, $top_left_lon, $bottom_right_lat, $bottom_right_lon) = split ',', $args{boundingbox}; |
1432 |
$filter{geo_bounding_box} = { |
1433 |
'geolocation' => { |
1434 |
'top_left' => { |
1435 |
'lat' => $top_left_lat, |
1436 |
'lon' => $top_left_lon, |
1437 |
}, |
1438 |
'bottom_right' => { |
1439 |
'lat' => $bottom_right_lat, |
1440 |
'lon' => $bottom_right_lon, |
1441 |
} |
1442 |
}, |
1443 |
}; |
1444 |
} else { |
1445 |
warn "Unrecognized parameter set for geolocation queries: " . join(', ', keys %args); |
1446 |
} |
1429 |
} else { |
1447 |
} else { |
1430 |
warn "unknown advanced ElasticSearch query: " . join( ', ', %$advanced_query ); |
1448 |
warn "unknown advanced ElasticSearch query: " . join( ', ', %$advanced_query ); |
1431 |
} |
1449 |
} |