From 6e97d624f0183c032cebe5d85c041be8a243eaab Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 11 Apr 2025 12:36:40 +0000 Subject: [PATCH] Bug 39503: [alternate] Collapse thesaurus if value in 008/_11 and 040 --- Koha/SearchEngine/Elasticsearch.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 945dcd9e7ad..9098a4eaa3e 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -918,6 +918,14 @@ sub marc_records_to_documents { } } + if ( $self->index eq $AUTHORITIES_INDEX && scalar @{ $record_document->{'subject-heading-thesaurus'} } > 1 ) { + + # We should really only have two thesauri defined in the case where 008/_11 = 'z' and 040$f is defined + # In that case, we should drop the z + @{ $record_document->{'subject-heading-thesaurus'} } = + map { $_ eq 'z' ? () : $_ } @{ $record_document->{'subject-heading-thesaurus'} }; + } + # Check if there is at least one available item if ( $self->index eq $BIBLIOS_INDEX ) { my ( $tag, $code ) = C4::Biblio::GetMarcFromKohaField('biblio.biblionumber'); -- 2.39.5