From 5987870b7aa4d11ea23d795db6babc53f914643d 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 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index 1603fbbc31..f547bbff81 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 =~ /^8/ ? '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( -- 2.39.5