Bugzilla – Attachment 161052 Details for
Bug 35815
[Elasticsearch] Fix indexing of bibliographic records when items are deleted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35815: Ensure ES biblio index is updated when items are batch deleted
Bug-35815-Ensure-ES-biblio-index-is-updated-when-i.patch (text/plain), 5.16 KB, created by
Aleisha Amohia
on 2024-01-16 02:34:49 UTC
(
hide
)
Description:
Bug 35815: Ensure ES biblio index is updated when items are batch deleted
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2024-01-16 02:34:49 UTC
Size:
5.16 KB
patch
obsolete
>From fafac9ea7169a153ce9e0da105019949ec4f2dbd Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 16 Jan 2024 02:31:32 +0000 >Subject: [PATCH] Bug 35815: Ensure ES biblio index is updated when items are > batch deleted > >This patch moves the Elasticsearch indexing outside of the transaction. This ensures that bibliographic records are reindexed when items are batch deleted. > >To test: > >1. Spin up a Koha instance in your testing environment which uses Elasticsearch >2. Create a new bibliographic record and add three items to it >3. Do a search for your record that will return multiple results, so that you are shown the search results. Confirm that the search results shows three items are attached to the record. >4. Go to the record and select the checkbox for an item. >5. Click the link to Delete selected items. Confirm this again on the next page. >6. Confirm the job is enqueued then completed. It should say your item has been deleted. >7. Do a search for your record again so that you see it in the search results. Notice the number of items has not been updated - it still says three --> BUG > >8. Apply the patch and restart services > >9. Go to the record (there will be two items now) and select the checkbox for one item. >10. Click the link to Delete selected items. Confirm this again on the next page. >11. Confirm the job is enqueued then completed. It should say your item has been deleted. >12. Do a search for your record again so that you see it in the search results. Confirm the number of items HAS been updated. It should now show one item attached to the record. > >Sponsored-by: Toi Ohomai Institute of Technology >--- > Koha/BackgroundJob/BatchDeleteItem.pm | 53 +++++++++++++-------------- > 1 file changed, 26 insertions(+), 27 deletions(-) > >diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm >index 474450e57b2..8ac5a4cd84a 100644 >--- a/Koha/BackgroundJob/BatchDeleteItem.pm >+++ b/Koha/BackgroundJob/BatchDeleteItem.pm >@@ -90,8 +90,10 @@ sub process { > }; > my @messages; > my $schema = Koha::Database->new->schema; >- my ( @deleted_itemnumbers, @not_deleted_itemnumbers, >- @deleted_biblionumbers ); >+ my ( >+ @deleted_itemnumbers, @not_deleted_itemnumbers, >+ @deleted_biblionumbers, @updated_biblionumbers >+ ); > > try { > my $schema = Koha::Database->new->schema; >@@ -131,7 +133,6 @@ sub process { > } > > # If there are no items left, delete the biblio >- my @updated_biblionumbers; > for my $biblionumber ( uniq @biblionumbers ) { > my $items_count = > Koha::Biblios->find($biblionumber)->items->count; >@@ -145,36 +146,34 @@ sub process { > push @updated_biblionumbers, $biblionumber; > } > } >+ } >+ ); > >- if (@deleted_biblionumbers) { >- my $indexer = Koha::SearchEngine::Indexer->new( >- { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >+ if (@deleted_biblionumbers) { >+ my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); > >- $indexer->index_records( \@deleted_biblionumbers, >- 'recordDelete', "biblioserver", undef ); >+ $indexer->index_records( >+ \@deleted_biblionumbers, >+ 'recordDelete', "biblioserver", undef >+ ); > >- Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >- { >- biblio_ids => \@deleted_biblionumbers >- } >- ) if C4::Context->preference('RealTimeHoldsQueue'); >- } >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { biblio_ids => \@deleted_biblionumbers } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); >+ } > >- if (@updated_biblionumbers) { >- my $indexer = Koha::SearchEngine::Indexer->new( >- { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >+ if (@updated_biblionumbers) { >+ my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); > >- $indexer->index_records( \@updated_biblionumbers, >- 'specialUpdate', "biblioserver", undef ); >+ $indexer->index_records( >+ \@updated_biblionumbers, >+ 'specialUpdate', "biblioserver", undef >+ ); > >- Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >- { >- biblio_ids => \@updated_biblionumbers >- } >- ) if C4::Context->preference('RealTimeHoldsQueue'); >- } >- } >- ); >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { biblio_ids => \@updated_biblionumbers } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); >+ } > } > catch { > >-- >2.30.2
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 35815
: 161052