Koha-clms/Koha/SearchEngine
Nick Clemens 574bd4f1fa
Bug 39503: Collapse thesaurus if value in 008_/11 = 'z' and 040 $f
With bug 30280 and subsequent patches we attempt to respect the
thesaurus indication when linking with LinkerConsiderThesaurus on.
However, there are still cases when we link wrong.

This happens when thesaurus in bibliographic field 6XX is defined by
subfield $2. In such a case the authority record should have 008/11 = 'z'
and, according to https://www.loc.gov/marc/authority/ad008.html
(cf. comment for 008/11 = 'z': "A MARC code for the conventions used to
formulate the heading *may* be contained in subfield $f"), may or may have
thesaurus declared in 040 $f.

This is why we make a second search attempt in C4::Heading::_search,
but doing so we have to make sure that the resulting authority
record has not a different thesaurus declared in 040 $f. (Note
that 008/11 and 040 $f are indexed with  the same search
field: subject-heading-thesaurus. So we search for the
second time in the same search field but with
'notdefined' == 008/11='z' instead of the original
thesaurus taken from subfield $2 of the bibliographic
field 6XX.) This means we have to explicitly check the
content of 040 $f of the resulting authority record.

Test plan:
==========
1. Turn on the LinkerConsiderThesaurus systempreference.
2. Create an authority record (e.g. TOPIC_TERM) with 008/11 = 'z' and
   040 $f containing a thesaurus indication (e.g. 'kaba'), and a term
   in field 150 $a (e.g. Early music).
3. Edit a bibliographic record: in field 650 put 2nd indicator '7',
   the term 'Early music' in $a, and a different thesaurus code in $2
   (e.g. 'dbn'). Click the 'Link authorities automatically' button.
   Note that 650 'Early music' (dbn) has been linked with and authority
   record 'Early music' (kaba). This is wrong.
4. Apply the patch ; restart_all ; reindex ES for authorities with:
   koha-elasticsearch --rebuild -d -a kohadev
5. Repeat p. 3. Now the 650 'Early music' (dbn) has not been linked to
   an authority record (650 - No matching authority found.)

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-05-13 18:47:00 +02:00
..
Elasticsearch Bug 39079: Follow 'and_or' variable when passed to build_auth_query_compat 2025-05-12 18:31:20 +02:00
Zebra Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Elasticsearch.pm Bug 39503: Collapse thesaurus if value in 008_/11 = 'z' and 040 $f 2025-05-13 18:47:00 +02:00
Indexer.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
QueryBuilder.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Search.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00