Bug 39076: Use state variable to avoid creating extra ES connections

As elsewhere in the code, we should use a state variable for our
'bib_searcher' object to avoid overhead of extra ES connections.

Worth noting - we don't actually use the 'bib_searcher' at all during
record auto linking as we pass skipmetadata

To test:
0 - Apply patch
1 - Enable biblio auto linking
    AutoLinkBiblios, CatalogModuleRelink, LinkerRelink
2 - Stage and import a marc file
3 - Confirm record authorities link as expected
4 - Search authorities in the staff interface
5 - Confirm usage counts are shown for results

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2025-02-10 13:09:31 +00:00 committed by Katrin Fischer
parent 8c0d196ff6
commit e2207cb478
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 2 additions and 1 deletions

View File

@ -217,7 +217,8 @@ sub search_auth_compat {
my $schema = $database->schema();
my $res = $self->search( $query, undef, $count, %options );
my $bib_searcher = Koha::SearchEngine::Elasticsearch::Search->new( { index => 'biblios' } );
# Use state variables to avoid recreating the objects every time.
state $bib_searcher = Koha::SearchEngine::Elasticsearch::Search->new( { index => 'biblios' } );
my @records;
my $hits = $res->{'hits'};
foreach my $es_record ( @{ $hits->{'hits'} } ) {