From 2b777fba1e06309d7705f236aab9f408f6c0176b Mon Sep 17 00:00:00 2001
From: Aleisha Amohia <aleishaamohia@hotmail.com>
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.
---
 C4/Biblio.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 9790febdaa..4e296bc53c 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -296,6 +296,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.20.1