From d2b14b47fd8c5e3ffd072556d945eba3d7418de0 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Mon, 12 Feb 2024 16:27:00 +0000 Subject: [PATCH] Bug 36069: (bug 29990 follow-up) authority heading use in search results should work with ES as well It seems that the enhancement introduced with bug 29990 (syspref: ShowHeadingUse) works only with Zebra (generation of main/subject/series use info is made only in C4::AuthoritiesMarc == a Zebra incarnation of search_auth_compat) and has no effect on ES search results. This patch does the same for ES. Test plan: 1. Have an installation with Elasticsearch enabled. 2. Go to Koha Administration -> system preferences -> searching tab. Enable ShowHeadingUse system preference. 3. Do an authority search. Notice that in the Heading use column you get always 'x' for all use types: main/subject/series. 4. Apply the patch. 5. Do an authority search. Notice that you get now 'v' or 'x' for use types main/subject/series, depending on the 008/14-16 bytes. Signed-off-by: Roman Dolny --- Koha/SearchEngine/Elasticsearch/Search.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index 933b52f79d..2f164b6397 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -250,6 +250,17 @@ sub search_auth_compat { $result{summary} = C4::AuthoritiesMarc::BuildSummary( $marc, $result{authid}, $authtypecode ); + if ( C4::Context->preference('ShowHeadingUse') ) { + # checking valid heading use + my $f008 = $marc->field('008'); + my $pos14to16 = substr( $f008->data, 14, 3 ); + my $main = substr( $pos14to16, 0, 1 ); + $result{main} = 1 if $main eq 'a'; + my $subject = substr( $pos14to16, 1, 1); + $result{subject} = 1 if $subject eq 'a'; + my $series = substr( $pos14to16, 2, 1 ); + $result{series} = 1 if $series eq 'a'; + } $result{used} = $self->count_auth_use($bib_searcher, $authid); } push @records, \%result; -- 2.30.2