Bug 24807: Add suppport for uncertain fields and ranges
To test:
1 - Have some records with uncertain dates in the 008
19uu, 195u, etc.
2 - Index them in Elasticsearch
3 - Do a search that will return them
4 - Sort results by publication/copyright date
5 - Note odd results
6 - Apply patch
7 - Reindex
8 - Sorting should be improved
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
19c5db6637
commit
4cae9b49f3
|
|
@ -481,7 +481,7 @@ sub _process_mappings {
|
|||
}
|
||||
if (defined $options->{filter_callbacks}) {
|
||||
# Skip mapping unless all filter callbacks return true
|
||||
next unless all { $_->($_data) } @{$options->{filter_callbacks}};
|
||||
next unless all { $_data = $_->($_data) } @{$options->{filter_callbacks}};
|
||||
}
|
||||
if (defined $options->{property}) {
|
||||
$_data = {
|
||||
|
|
@ -497,7 +497,11 @@ sub _process_mappings {
|
|||
}
|
||||
|
||||
$record_document->{$target} //= [];
|
||||
push @{$record_document->{$target}}, $_data;
|
||||
if( ref $_data eq 'ARRAY' ){
|
||||
push @{$record_document->{$target}}, @{$_data};
|
||||
} else {
|
||||
push @{$record_document->{$target}}, $_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -896,7 +900,13 @@ sub _field_mappings {
|
|||
$default_options->{filter_callbacks} //= [];
|
||||
push @{$default_options->{filter_callbacks}}, sub {
|
||||
my ($value) = @_;
|
||||
return $value =~ /^\d+$/;
|
||||
my @years = ();
|
||||
my @field_years = ( $value =~ /[0-9u]{4}/g );
|
||||
foreach my $year (@field_years){
|
||||
$year =~ s/[u]/0/g;
|
||||
push @years, $year;
|
||||
}
|
||||
return \@years;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue