Bug 33277: Do not search using thesaurus when linking non 6XX fields

This patch sets thesaurus as undefined when linking any field except 6XX

This fixes the case where authrotiy records don't have the thesaurus defined

Consequently - this means that Koha does not support multiple thesaurus records
for authorities outside of subjects

i.e. Using the default linker, and having both an LCSH and Sears record for 'Shakespeare,William'
A 100 entry will find two results and the heading won't be linked. Previously we always linked to the LCSH

To test:
1 - Import the attached auths and biblio (from bug 33159 comment 24)
2 - Set system preferences:
    RequireChoosingExistingAuthority - don't require
    AutoCreateAuthorities - don't generate
    CatalogModuleRelink - Do
    LinkerKeepStale - Don't
    LinkerModule - default
    LinkerRelink - do
3 - Edit the imported bib
4 - Save it
5 - Headings are not linked except 600
6 - Apply patch
7 - Restart all
8 - Edit and save record
9 - Headings are successfully linked

Signed-off-by: Frank Hansen <frank.hansen@ub.lu.se>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit d73f567366)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2023-03-20 15:44:17 +00:00 committed by Matt Blenkinsop
parent 7d05952894
commit 1bf99e3e5c
3 changed files with 3 additions and 6 deletions

View File

@ -339,7 +339,7 @@ sub parse_heading {
my $thesaurus =
$tag =~ m/6../
? _get_subject_thesaurus($field)
: "lcsh"; # use 'lcsh' for names, UT, etc.
: undef; # We can't know the thesaurus for non-subject fields
my $search_heading =
_get_search_heading( $field, $field_info->{'subfields'} );
my $display_heading =

View File

@ -114,7 +114,6 @@ subtest "_search tests" => sub {
$terms = $search_query->{query}->{bool}->{must};
$expected_terms = [
{ term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } },
{ term => { 'subject-heading-thesaurus.ci_raw' => 'a' } },
];
is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with single punctuation mark");
@ -124,7 +123,6 @@ subtest "_search tests" => sub {
$terms = $search_query->{query}->{bool}->{must};
$expected_terms = [
{ term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } },
{ term => { 'subject-heading-thesaurus.ci_raw' => 'a' } },
];
is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with double punctuation, hyphen+comma");
@ -134,7 +132,6 @@ subtest "_search tests" => sub {
$terms = $search_query->{query}->{bool}->{must};
$expected_terms = [
{ term => { 'match-heading.ci_raw' => 'Tolkien, J.R.R' } },
{ term => { 'subject-heading-thesaurus.ci_raw' => 'a' } },
];
is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with double punctuation, period+comma ");

View File

@ -25,12 +25,12 @@ SKIP: {
$heading = C4::Heading->new_from_field($field);
is($heading->display_form(), 'The dark is rising ;', 'Display form generation');
is($heading->search_form(), 'The dark is rising', 'Search form generation');
is($heading->{thesaurus}, 'lcsh', 'Thesaurus generation');
ok( !defined $heading->{thesaurus}, 'Thesaurus is not generated outside of 6XX fields');
$field = MARC::Field->new( '100', '1', '', a => 'Yankovic, Al', d => '1959-' );
$heading = C4::Heading->new_from_field($field);
is($heading->display_form(), 'Yankovic, Al 1959-', 'Display form generation');
is($heading->search_form(), 'Yankovic, Al 1959', 'Search form generation');
is($heading->{thesaurus}, 'lcsh', 'Thesaurus generation');
ok( !defined $heading->{thesaurus}, 'Thesaurus is not generated outside of 6XX fields');
}