Bugzilla – Attachment 108385 Details for
Bug 24807
Add "year" type to improve sorting by publication date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24807: Add suppport for uncertain fields and ranges
Bug-24807-Add-suppport-for-uncertain-fields-and-ra.patch (text/plain), 2.12 KB, created by
Nick Clemens (kidclamp)
on 2020-08-17 10:02:59 UTC
(
hide
)
Description:
Bug 24807: Add suppport for uncertain fields and ranges
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-08-17 10:02:59 UTC
Size:
2.12 KB
patch
obsolete
>From 53e897c6ce68bdc3802ae21f0e1aa6fc8c69a52e Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 8 Apr 2020 09:55:20 +0000 >Subject: [PATCH] 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> >--- > Koha/SearchEngine/Elasticsearch.pm | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index fec5f3fd45..e3c3a6f5bd 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -485,7 +485,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 = { >@@ -501,7 +501,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; > }; > } > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24807
:
100170
|
100171
|
100176
|
102547
|
102548
|
103084
|
103085
|
103086
|
103087
|
103163
|
103277
|
104525
|
104526
|
104527
|
104528
|
104529
|
104530
|
104531
|
106768
|
108382
|
108383
|
108384
|
108385
|
108386
|
108387
|
108388
|
108389
|
109997
|
109998
|
109999
|
110000
|
110001
|
110002
|
110003
|
110004
|
110355
|
110884