Bugzilla – Attachment 107434 Details for
Bug 25273
Elasticsearch Authority matching is returning too many results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25273: (follow-up)
Bug-25273-follow-up.patch (text/plain), 7.21 KB, created by
Nick Clemens (kidclamp)
on 2020-07-27 15:00:14 UTC
(
hide
)
Description:
Bug 25273: (follow-up)
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-07-27 15:00:14 UTC
Size:
7.21 KB
patch
obsolete
>From 47fc87d1b6c469e39d5ea0292fe496bbcd5c3a1a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 9 Jul 2020 18:40:01 +0000 >Subject: [PATCH] Bug 25273: (follow-up) > >--- > C4/AuthoritiesMarc.pm | 2 +- > C4/Biblio.pm | 10 ++++------ > Koha/SearchEngine/Elasticsearch.pm | 7 ++++--- > misc/search_tools/rebuild_elasticsearch.pl | 8 +++----- > t/db_dependent/Koha/SearchEngine/Elasticsearch.t | 17 ++++------------- > 5 files changed, 16 insertions(+), 28 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 94fefcdd3c..bd25837c36 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -628,7 +628,7 @@ sub AddAuthority { > $record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); > # Update > $dbh->do( "UPDATE auth_header SET authtypecode=?, marc=?, marcxml=? WHERE authid=?", undef, $authtypecode, $record->as_usmarc, $record->as_xml_record($format), $authid ) or die $DBI::errstr; >- ModZebra( $authid, 'specialUpdate', 'authorityserver', { record => $record, authtypecode => $authtypecode } ); >+ ModZebra( $authid, 'specialUpdate', 'authorityserver', $record ); > > return ( $authid ); > } >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index a5bf470cf9..32e4e1c7b9 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2545,8 +2545,8 @@ $op is specialUpdate or recordDelete, and is used to know what we want to do > > $server is the server that we want to update > >-$record is a hash including the authtypecode and updated MARC record. This is only used for >-Elasticsearch authorities. If it's not supplied a biblio will be loaded from the database. >+$record is the updated MARC record. If it's not supplied >+and is needed it will be loaded from the database. > > =cut > >@@ -2566,14 +2566,12 @@ sub ModZebra { > } > ); > if ( $op eq 'specialUpdate' ) { >- if ($record) { >- $indexer->update_index_background( [$biblionumber], [$record] ); >- } else { >+ unless ($record) { > $record = GetMarcBiblio({ > biblionumber => $biblionumber, > embed_items => 1 }); >- $indexer->update_index_background( [$biblionumber], [{ record => $record }] ); > } >+ $indexer->update_index_background( [$biblionumber], [$record] ); > } > elsif ( $op eq 'recordDelete' ) { > $indexer->delete_index_background( [$biblionumber] ); >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index f3e663e54a..a678ea2610 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -28,6 +28,7 @@ use Koha::SearchFields; > use Koha::SearchMarcMaps; > use Koha::Caches; > use C4::Heading; >+use C4::AuthoritiesMarc; > > use Carp; > use Clone qw(clone); >@@ -536,12 +537,12 @@ sub marc_records_to_documents { > foreach my $record (@{$records}) { > my $record_document = {}; > >- if ( defined $record->{authtypecode} ){ >- my $field = $record->{record}->field( $auth_match_headings{ $record->{authtypecode} } ); >+ if ( $self->index eq 'authorities' ){ >+ my $authtypecode = GuessAuthTypeCode( $record ); >+ my $field = $record->field( $auth_match_headings{ $authtypecode } ); > my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading > push @{$record_document->{'match-heading'}}, $heading->search_form if $heading; > } >- $record = $record->{record}; > > my $mappings = $rules->{leader}; > if ($mappings) { >diff --git a/misc/search_tools/rebuild_elasticsearch.pl b/misc/search_tools/rebuild_elasticsearch.pl >index 8bb6110ba1..6cff2eae2e 100755 >--- a/misc/search_tools/rebuild_elasticsearch.pl >+++ b/misc/search_tools/rebuild_elasticsearch.pl >@@ -275,10 +275,8 @@ sub _do_reindex { > my $commit_count = $commit; > my ( @id_buffer, @commit_buffer ); > while ( my $record = $next->() ) { >- my $id = $record->id; >- my $record_prepped; >- $record_prepped->{authtypecode} = $record->authtypecode if ref $record eq 'Koha::MetadataRecord::Authority'; >- $record_prepped->{record} = $record->record; >+ my $id = $record->id // $record->authid; >+ my $record = $record->record; > $count++; > if ( $verbose == 1 ) { > _log( 1, "$count records processed\n" ) if ( $count % 1000 == 0); >@@ -287,7 +285,7 @@ sub _do_reindex { > } > > push @id_buffer, $id; >- push @commit_buffer, $record_prepped; >+ push @commit_buffer, $record; > if ( !( --$commit_count ) ) { > _log( 1, "Committing $commit records...\n" ); > my $response = $indexer->update_index( \@id_buffer, \@commit_buffer ); >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t >index 6ae3d392fa..471baf34e1 100644 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t >@@ -340,10 +340,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' > MARC::Field->new('999', '', '', c => '1234568'), > MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), > ); >- my $records = [ >- { record => $marc_record_1 }, >- { record => $marc_record_2 }, >- ]; >+ my $records = [ $marc_record_1, $marc_record_2 ]; > > $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first > >@@ -510,7 +507,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' > $large_marc_record->append_fields($item_field); > } > >- $docs = $see->marc_records_to_documents([{ record => $large_marc_record }]); >+ $docs = $see->marc_records_to_documents([$large_marc_record]); > > is($docs->[0]->{marc_format}, 'MARCXML', 'For record exceeding max record size marc_format should be set correctly'); > >@@ -623,10 +620,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t > MARC::Field->new('999', '', '', c => '1234568'), > MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric'), > ); >- my $records = [ >- { record => $marc_record_1 }, >- { record => $marc_record_2 }, >- ]; >+ my $records = [ $marc_record_1, $marc_record_2 ]; > > $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first > >@@ -701,10 +695,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori > $marc_record_2->append_fields( > MARC::Field->new('150', '', '', a => 'Subject', v => 'Genresubdiv', z => 'Geosubdiv', x => 'Generalsubdiv', e => 'wrongsubdiv' ), > ); >- my $records = [ >- { record => $marc_record_1, authtypecode=> $auth_type->authtypecode }, >- { record => $marc_record_2, authtypecode=> $auth_type->authtypecode }, >- ]; >+ my $records = [ $marc_record_1, $marc_record_2 ]; > > $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first > >-- >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 25273
:
103801
|
103854
|
104363
|
105435
|
106759
|
107434
|
108989
|
109261
|
109262
|
109263