Lines 136-141
our %index_field_convert = (
Link Here
|
136 |
); |
136 |
); |
137 |
my $field_name_pattern = '[\w\-]+'; |
137 |
my $field_name_pattern = '[\w\-]+'; |
138 |
my $multi_field_pattern = "(?:\\.$field_name_pattern)*"; |
138 |
my $multi_field_pattern = "(?:\\.$field_name_pattern)*"; |
|
|
139 |
my $es_advanced_searches = []; |
139 |
|
140 |
|
140 |
=head2 get_index_field_convert |
141 |
=head2 get_index_field_convert |
141 |
|
142 |
|
Lines 244-249
sub build_query {
Link Here
|
244 |
or $display_library_facets eq 'holding' ) { |
245 |
or $display_library_facets eq 'holding' ) { |
245 |
$res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } }; |
246 |
$res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } }; |
246 |
} |
247 |
} |
|
|
248 |
|
249 |
$res = _rebuild_to_es_advanced_query($res) if @$es_advanced_searches ; |
247 |
return $res; |
250 |
return $res; |
248 |
} |
251 |
} |
249 |
|
252 |
|
Lines 908-913
operand.
Link Here
|
908 |
|
911 |
|
909 |
sub _create_query_string { |
912 |
sub _create_query_string { |
910 |
my ( $self, @queries ) = @_; |
913 |
my ( $self, @queries ) = @_; |
|
|
914 |
foreach my $q (@queries) { |
915 |
if ($q->{field} && $q->{field} eq 'geolocation') { |
916 |
push(@$es_advanced_searches, $q); |
917 |
} |
918 |
} |
919 |
@queries = grep { $_->{field} ne 'geolocation' } @queries; |
911 |
|
920 |
|
912 |
map { |
921 |
map { |
913 |
my $otor = $_->{operator} ? $_->{operator} . ' ' : ''; |
922 |
my $otor = $_->{operator} ? $_->{operator} . ' ' : ''; |
Lines 1061-1067
sub _fix_limit_special_cases {
Link Here
|
1061 |
|
1070 |
|
1062 |
my @new_lim; |
1071 |
my @new_lim; |
1063 |
foreach my $l (@$limits) { |
1072 |
foreach my $l (@$limits) { |
1064 |
|
|
|
1065 |
# This is set up by opac-search.pl |
1073 |
# This is set up by opac-search.pl |
1066 |
if ( $l =~ /^yr,st-numeric,ge[=:]/ ) { |
1074 |
if ( $l =~ /^yr,st-numeric,ge[=:]/ ) { |
1067 |
my ( $start, $end ) = |
1075 |
my ( $start, $end ) = |
Lines 1291-1294
sub _search_fields {
Link Here
|
1291 |
} |
1299 |
} |
1292 |
} |
1300 |
} |
1293 |
|
1301 |
|
|
|
1302 |
sub _rebuild_to_es_advanced_query { |
1303 |
my ($res) = @_; |
1304 |
my $query_string = $res->{query}->{query_string}; |
1305 |
$query_string->{query} = '*' unless $query_string->{query}; |
1306 |
delete $res->{query}->{query_string}; |
1307 |
|
1308 |
my %filter; |
1309 |
for my $advanced_query (@$es_advanced_searches) { |
1310 |
if ( $advanced_query->{field} eq 'geolocation') { |
1311 |
my ($lat, $lon, $distance) = map { $_ =~ /:(.*)\*/ } split('\s+', $advanced_query->{operand}); |
1312 |
$filter{geo_distance} = { |
1313 |
distance => $distance, |
1314 |
geolocation => { |
1315 |
lat => $lat, |
1316 |
lon => $lon, |
1317 |
} |
1318 |
}; |
1319 |
} |
1320 |
else { |
1321 |
warn "unknown advanced ElasticSearch query: ".join(', ',%$advanced_query); |
1322 |
} |
1323 |
} |
1324 |
|
1325 |
$res->{query} = { |
1326 |
bool => { |
1327 |
must => { |
1328 |
query_string => $query_string |
1329 |
}, |
1330 |
filter => \%filter, |
1331 |
} |
1332 |
}; |
1333 |
|
1334 |
return $res; |
1335 |
} |
1336 |
|
1337 |
|
1294 |
1; |
1338 |
1; |