Bugzilla – Attachment 110548 Details for
Bug 23828
Elasticsearch - ES - Authority record results not ordered correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23828: Elasticsearch - Preserve record order when combining subfield in mappings
Bug-23828-Elasticsearch---Preserve-record-order-wh.patch (text/plain), 3.31 KB, created by
Andrew Fuerste-Henry
on 2020-09-22 12:32:16 UTC
(
hide
)
Description:
Bug 23828: Elasticsearch - Preserve record order when combining subfield in mappings
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2020-09-22 12:32:16 UTC
Size:
3.31 KB
patch
obsolete
>From 51717444d2c333a3efe1903e349c1f5c5bca0b0d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 16 Sep 2020 11:31:54 +0000 >Subject: [PATCH] Bug 23828: Elasticsearch - Preserve record order when > combining subfield in mappings > >Currently if you combine subfields in the marc mappings the subfields are indexed in the order >listed in the mapping. > >i.e. 650(avxyz) in mapping > >and in record: >650 $aHeading $zGeosubdiv $vFormsubdiv > >is indexed as: >Heading Formsubdiv Geosubdiv > >We should preserve the order and index as: >Heading Geosubdiv Formsubdiv > >We can use built in function in Marc::Field to achieve this > >To test: > 1 - It is easy to find examples of this using authorities > 2 - Find or create a record with subfields order azv > e.g. 150$aActresses$zUnited states$vBiography > 3 - Add or have a second authority > e.g. 150$aActresses$vPortraits > 4 - Set an authorities mapping for 'Heading' to 150(abgvxyz) > find at: > Administration->Search engine configuration (Elasticsearch)->Authorities tab > 5 - Index the records in Elasticsearch > perl misc/search_tools/rebuild_elaticsearch.pl -a -ai 1691 -ai 1692 > 6 - View the first record in the ES index > curl es:9200/koha_kohadev_authorities/data/1692?pretty > 7 - Note 'Heading' field is ordered as in the mapping > 8 - Search authorities for 'contains' "act" > 9 - Note the records sort incorrectly >10 - Apply patches >11 - perl misc/search_tools/rebuild_elaticsearch.pl -a -ai 1692 >12 - curl es:9200/koha_kohadev_authorities/data/1692?pretty >13 - Note the order is now preserved >14 - Search authorities for 'contains' "act" >15 - Note the records sort correctly > >Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov> >--- > Koha/SearchEngine/Elasticsearch.pm | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 1df589c07c..e4edbb5acb 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -617,14 +617,9 @@ sub marc_records_to_documents { > my $subfields_join_mappings = $data_field_rules->{subfields_join}; > if ($subfields_join_mappings) { > foreach my $subfields_group (keys %{$subfields_join_mappings}) { >- # Map each subfield to values, remove empty values, join with space >- my $data = join( >- ' ', >- grep( >- $_, >- map { join(' ', $field->subfield($_)) } split(//, $subfields_group) >- ) >- ); >+ my $data_field = $field->clone; #copy field to preserve for alt scripts >+ $data_field->delete_subfield(match => qr/^$/); #remove empty subfields, otherwise they are printed as a space >+ my $data = $data_field->as_string( $subfields_group ); #get values for subfields as a combind string, preserving record order > if ($data) { > $self->_process_mappings($subfields_join_mappings->{$subfields_group}, $data, $record_document, { > altscript => $altscript, >-- >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 23828
:
110175
|
110176
|
110547
|
110548
|
111329
|
111330
|
111813
|
111814
|
111815
|
112142
|
112143