From d8fd73bee24b156f5bfe745f71ba3707b8248a7a Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Wed, 20 Nov 2024 13:18:05 +0000 Subject: [PATCH] Bug 38494: Koha should consider authority heading use in cataloging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In MARC 21 authority records, three bytes (008/14-16) indicate what the heading can be used for (main/added entry, subject entry, series entry). Koha should be able to respect the record's intended use in authority search during cataloging, provided that the authority file is well formed. Also, we should be able to decide between more strict but correct behavior and current lax behavior. Test plan: ---------- 1. Apply the patch; updatedatabase ; restart_all 2. Set the ShowHeadingUse system preference to ‘Show’ 3. Go to the Cataloging editor and open the authority finder plugin for the 100 field. Search for Peter. With standard ktd test data you should get 9 results, some with ‘v’ before Main/Added Entry, some with ‘x’. These with ‘x’ are not to be used in this context, provided you use a well-formed authority file 4. Set ConsiderHeadingUse system preference to ‘Do’ 5. Repeat p. 3. You should get now only 4 Peters – those with ‘v’ before Main/Added Entry (008/14 = ‘a’) 6. You can repeat the test for subject headings (6XX) and series headings (sometimes you would have to modify the test data, e.g. there are few authority records with 008/16 = ‘a’ (series use) 7. This should work equally with Zebra and with Elasticsearch Sponsored-by: Ignatianum University in Cracow --- authorities/auth_finder.pl | 19 +++++++++++++++++++ .../bug_38494-ConsiderHeadingUse_syspref.pl | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index 1603fbbc31..819b59f75f 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -68,6 +68,25 @@ if ( $op eq "do_search" ) { my $startfrom = $query->param('startfrom') || 0; my $resultsperpage = $query->param('resultsperpage') || 20; + if ( C4::Context->preference('ConsiderHeadingUse') ) { + my $marcflavour = C4::Context->preference('marcflavour'); + my $biblio_tag = substr( $index, 4, 3 ); + if ( $marcflavour eq 'MARC21' ) { + my $heading_use_search_field = + $biblio_tag =~ /^[127]/ ? 'Heading-use-main-or-added-entry' + : $biblio_tag =~ /^6/ ? 'Heading-use-subject-added-entry' + : $biblio_tag =~ /^[48]/ ? 'Heading-use-series-added-entry' + : undef; + if ($heading_use_search_field) { + push @marclist, $heading_use_search_field; + push @and_or, 'and'; + push @excluding, ''; + push @operator, 'is'; + push @value, 'a'; + } + } + } + my $builder = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); my $searcher = Koha::SearchEngine::Search->new( diff --git a/installer/data/mysql/atomicupdate/bug_38494-ConsiderHeadingUse_syspref.pl b/installer/data/mysql/atomicupdate/bug_38494-ConsiderHeadingUse_syspref.pl index b72ae8ae53..a299fcc645 100755 --- a/installer/data/mysql/atomicupdate/bug_38494-ConsiderHeadingUse_syspref.pl +++ b/installer/data/mysql/atomicupdate/bug_38494-ConsiderHeadingUse_syspref.pl @@ -9,7 +9,7 @@ return { my ( $dbh, $out ) = @$args{qw(dbh out)}; $dbh->do( -q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('ConsiderHeadingUse', '0', NULL, 'Consider authority heading use (main/added entry, or subject, or series title) in cataloging and linking', 'YesNo')} + q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('ConsiderHeadingUse', '0', NULL, 'Consider authority heading use (main/added entry, or subject, or series title) in cataloging and linking', 'YesNo')} ); say_success( $out, "Added system preference 'ConsiderHeadingUse'" ); -- 2.39.5