Bug 42795: Do not try to update ES mappings if not using ES patch for main

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Lucas Gass 2026-06-09 22:14:11 +00:00 committed by Pedro Amorim
parent 2d72d4e17a
commit 82d189a756
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 11 additions and 3 deletions

View File

@ -28,9 +28,17 @@ return {
}, undef, $local_number_map_id
);
my $index_name = $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX;
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( { index => $index_name } );
$indexer->update_mappings();
# We do want to update the mappings in the DB in case ES gets switched on
# but just skip the ES engine update if ES not enabled
my $searchengine =
$dbh->selectrow_array(q|SELECT value FROM systempreferences WHERE variable = 'SearchEngine'|);
if ( $searchengine eq 'Elasticsearch' ) {
my $index_name = $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX;
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( { index => $index_name } );
$indexer->update_mappings();
} else {
say $out "ES disabled, mappings not updated";
}
say $out "Updated ES mappings to make local-number sortable";
} elsif ( !defined $local_number_map_id ) {
say_warning( $out, "No mapping defined for local-number" );