Bugzilla – Attachment 110737 Details for
Bug 25265
Elasticsearch - Batch editing items on a biblio can lead to incorrect index
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25265: (QA follow-up) Check server type in Elasticsearch::index_records
Bug-25265-QA-follow-up-Check-server-type-in-Elasti.patch (text/plain), 3.80 KB, created by
Marcel de Rooy
on 2020-09-25 09:44:23 UTC
(
hide
)
Description:
Bug 25265: (QA follow-up) Check server type in Elasticsearch::index_records
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-09-25 09:44:23 UTC
Size:
3.80 KB
patch
obsolete
>From e39ef665695898623e43802ead46079a841eabc7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 25 Sep 2020 07:42:44 +0000 >Subject: [PATCH] Bug 25265: (QA follow-up) Check server type in > Elasticsearch::index_records >Content-Type: text/plain; charset=utf-8 > >Doing the same change as previously (renaming biblionumber), but fixing >at the same the record fetch. If (theoretically) an authority is passed >without a record, it would have fetched a biblio record. > >Test plan: >You need Elasticsearch here. >Replaced this line in AddAuthority: > $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); >by > $indexer->index_records( $authid, "specialUpdate", "authorityserver", undef ); >And updated an authority record. Check if you can search for the change. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/SearchEngine/Elasticsearch/Indexer.pm | 29 +++++++++++++++++------------ > 1 file changed, 17 insertions(+), 12 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/Indexer.pm b/Koha/SearchEngine/Elasticsearch/Indexer.pm >index 87902a34e0..8e84bc1672 100644 >--- a/Koha/SearchEngine/Elasticsearch/Indexer.pm >+++ b/Koha/SearchEngine/Elasticsearch/Indexer.pm >@@ -284,7 +284,7 @@ sub update_index_background { > > =head2 index_records > >-This function takes an array of biblionumbers and fetches the records to send to update_index >+This function takes an array of record numbers and fetches the records to send to update_index > for actual indexing. > > If $records parameter is provided the records will be used as-is, this is only utilized for authorities >@@ -296,31 +296,36 @@ to Zebra as well. > =cut > > sub index_records { >- my ( $self, $biblionumbers, $op, $server, $records ) = @_; >- $biblionumbers = [$biblionumbers] if ref $biblionumbers ne 'ARRAY' && defined $biblionumbers; >+ my ( $self, $record_numbers, $op, $server, $records ) = @_; >+ $record_numbers = [$record_numbers] if ref $record_numbers ne 'ARRAY' && defined $record_numbers; > $records = [$records] if ref $records ne 'ARRAY' && defined $records; > if ( $op eq 'specialUpdate' ) { >- my $index_biblionumbers; >+ my $index_record_numbers; > unless ($records) { >- foreach my $biblionumber ( @$biblionumbers ){ >- my $record = C4::Biblio::GetMarcBiblio({ >- biblionumber => $biblionumber, >- embed_items => 1 }); >+ foreach my $record_number ( @$record_numbers ){ >+ my $record = _get_record( $record_number, $server ); > if( $record ){ > push @$records, $record; >- push @$index_biblionumbers, $biblionumber; >+ push @$index_record_numbers, $record_number; > } > } > } >- $self->update_index_background( $index_biblionumbers, $records ) if $index_biblionumbers && $records; >+ $self->update_index_background( $index_record_numbers, $records ) if $index_record_numbers && $records; > } > elsif ( $op eq 'recordDelete' ) { >- $self->delete_index_background( $biblionumbers ); >+ $self->delete_index_background( $record_numbers ); > } > #FIXME Current behaviour is to index Zebra when using ES, at some point we should stop >- Koha::SearchEngine::Zebra::Indexer::index_records( $self, $biblionumbers, $op, $server, undef ); >+ Koha::SearchEngine::Zebra::Indexer::index_records( $self, $record_numbers, $op, $server, undef ); > } > >+sub _get_record { >+ my ( $id, $server ) = @_; >+ return $server eq 'biblioserver' >+ ? C4::Biblio::GetMarcBiblio({ biblionumber => $id, embed_items => 1 }) >+ : C4::AuthoritiesMarc::GetAuthority($id); >+} >+ > =head2 delete_index($biblionums) > > C<$biblionums> is an arrayref of biblionumbers to delete from the index. >-- >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 25265
:
107832
|
107855
|
107867
|
109538
|
109556
|
110262
|
110263
|
110264
|
110380
|
110381
|
110382
|
110457
|
110458
|
110459
|
110560
|
110561
|
110562
|
110565
|
110594
|
110595
|
110596
|
110597
|
110615
|
110618
|
110729
|
110730
|
110731
|
110732
|
110733
|
110734
|
110736
| 110737 |
110882
|
110883
|
110937