Bugzilla – Attachment 103087 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.07 KB, created by
David Gustafsson
on 2020-04-16 12:53:17 UTC
(
hide
)
Description:
Bug 24807: Add suppport for uncertain fields and ranges
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2020-04-16 12:53:17 UTC
Size:
2.07 KB
patch
obsolete
>From 353175f30e80794eb18936497d5691d9869d9bab 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 >--- > 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 f575e95b08..34b6d0c807 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -482,7 +482,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 = { >@@ -498,7 +498,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; >+ } > } > } > >@@ -893,7 +897,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.20.1
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