From e14efcc536e7c057be4aa1a89a5105aa8b191049 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 15 Feb 2023 23:50:33 +1300 Subject: [PATCH] Bug 33019: Make sure ES records are indexed the first time This patch ensures records are indexed when they are created. Previously, we were launching the indexer inside of of a transaction. This meant that the job was being enqueued, but not being found by the worker, becaue it was not yet in the DB This patch skips record indexing in the transaction, and moves the indexing command after To test: 1 - Make sure you are using ES, and the es indexer is running 2 - tail -f /var/log/koha/kohadev/*.log 3 - Create a new record 4 - Note error in es-indexer-output.log like: [2023/03/21 12:22:36] [WARN] No job found for id=157 main:: /kohadevbox/koha/misc/workers/es_indexer_daemon.pl (129) 5 - Apply patch 6 - Create another record 7 There should be no error 8 - Search for the record and confirm it can be found 9 - View the background jobs in admin, confirm the most recent job has completed --- C4/Biblio.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 1af5e12696..7a045ca6b4 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -298,6 +298,11 @@ sub AddBiblio { _after_biblio_action_hooks({ action => 'create', biblio_id => $biblionumber }); logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog"); + + unless ( $skip_record_index ) { + my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); + $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" ); + } }); } catch { warn $_; -- 2.30.2