Lines 221-230
sub get_elasticsearch_mappings {
Link Here
|
221 |
$es_type = 'cn_sort'; |
221 |
$es_type = 'cn_sort'; |
222 |
} elsif ( $type eq 'geo_point' ) { |
222 |
} elsif ( $type eq 'geo_point' ) { |
223 |
$es_type = 'geo_point'; |
223 |
$es_type = 'geo_point'; |
224 |
} |
|
|
225 |
|
226 |
if ( $type eq 'geo_point' ) { |
227 |
$name =~ s/_(lat|lon)$//; |
224 |
$name =~ s/_(lat|lon)$//; |
|
|
225 |
} elsif ( $type eq 'geo_shape' ) { |
226 |
$es_type = 'geo_shape'; |
227 |
$name =~ s/_(north|south|east|west)ernmost$/_area/; |
228 |
} |
228 |
} |
229 |
|
229 |
|
230 |
if ($search) { |
230 |
if ($search) { |
Lines 878-883
sub marc_records_to_documents {
Link Here
|
878 |
delete $record_document->{$field}; |
878 |
delete $record_document->{$field}; |
879 |
} |
879 |
} |
880 |
|
880 |
|
|
|
881 |
my %shape_bounds; |
882 |
foreach my $field ( @{ $rules->{geo_shape} } ) { |
883 |
next unless $record_document->{$field}; |
884 |
$field =~ /([^_]+)_(north|south|east|west)ernmost$/; |
885 |
my $geofield = $1; |
886 |
my $direction = $2; |
887 |
$shape_bounds{$geofield}{$direction} = $record_document->{$field}; |
888 |
delete $record_document->{$field}; |
889 |
} |
890 |
for my $geofield ( keys %shape_bounds ) { |
891 |
my %bounds = %{ $shape_bounds{$geofield} }; |
892 |
if ( %bounds == 4 ) { |
893 |
my @shapes; |
894 |
for my $i ( 0 .. scalar( $bounds{north}->@* ) - 1 ) { |
895 |
$shapes[$i] = [ |
896 |
[ 0 + $bounds{west}[$i], 0 + $bounds{north}[$i] ], |
897 |
[ 0 + $bounds{east}[$i], 0 + $bounds{south}[$i] ], |
898 |
]; |
899 |
} |
900 |
my $es_field = $geofield . '_area'; |
901 |
$record_document->{$es_field} = [ |
902 |
map { |
903 |
+{ |
904 |
type => 'envelope', |
905 |
coordinates => $_, |
906 |
} |
907 |
} @shapes |
908 |
]; |
909 |
} |
910 |
} |
911 |
|
881 |
# Remove duplicate values and collapse sort fields |
912 |
# Remove duplicate values and collapse sort fields |
882 |
foreach my $field ( keys %{$record_document} ) { |
913 |
foreach my $field ( keys %{$record_document} ) { |
883 |
if ( ref( $record_document->{$field} ) eq 'ARRAY' ) { |
914 |
if ( ref( $record_document->{$field} ) eq 'ARRAY' ) { |
Lines 1255-1260
sub _get_marc_mapping_rules {
Link Here
|
1255 |
push @{ $rules->{isbn} }, $name; |
1286 |
push @{ $rules->{isbn} }, $name; |
1256 |
} elsif ( $type eq 'geo_point' ) { |
1287 |
} elsif ( $type eq 'geo_point' ) { |
1257 |
push @{ $rules->{geo_point} }, $name; |
1288 |
push @{ $rules->{geo_point} }, $name; |
|
|
1289 |
} elsif ( $type eq 'geo_shape' ) { |
1290 |
push @{ $rules->{geo_shape} }, $name; |
1258 |
} elsif ( $type eq 'boolean' ) { |
1291 |
} elsif ( $type eq 'boolean' ) { |
1259 |
|
1292 |
|
1260 |
# boolean gets special handling, if value doesn't exist for a field, |
1293 |
# boolean gets special handling, if value doesn't exist for a field, |