@@ -, +, @@ --- C4/Heading.pm | 2 ++ C4/Heading/MARC21.pm | 5 +++++ .../SearchEngine/Elasticsearch/QueryBuilder.pm | 18 ++++++++++++------ t/db_dependent/Heading.t | 3 +++ 4 files changed, 22 insertions(+), 6 deletions(-) --- a/C4/Heading.pm +++ a/C4/Heading.pm @@ -202,6 +202,8 @@ sub _search { my @operator; my @value; + # FIXME: We specify values for @and_or and @excluding + # but these fields are not used anywhere and should be removed if ($index) { push @marclist, $index; push @and_or, 'AND'; --- a/C4/Heading/MARC21.pm +++ a/C4/Heading/MARC21.pm @@ -359,6 +359,11 @@ sub _get_subject_thesaurus { my $field = shift; my $ind2 = $field->indicator(2); + # NOTE: sears and aat do not appear + # here as they do not have indicator values + # though the 008 in the authority records + # do have values for them + my $thesaurus = "notdefined"; if ( $ind2 eq '0' ) { $thesaurus = "lcsh"; --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -564,14 +564,20 @@ our $koha_to_index_name = { all => '' }; +# Note that sears and aat map to 008/11 values here +# but don't appear in C4/Headin/MARC21 thesaurus +# because they don't have values in controlled field indicators +# https://www.loc.gov/marc/authority/ad008.html our $thesaurus_to_value = { - lcsh => 'a', - lcac => 'b', - mesh => 'c', - nal => 'd', + lcsh => 'a', + lcac => 'b', + mesh => 'c', + nal => 'd', notspecified => 'n', - cash => 'k', - rvm => 'v', + cash => 'k', + rvm => 'v', + aat => 'r', + sears => 's' }; sub build_authorities_query_compat { --- a/t/db_dependent/Heading.t +++ a/t/db_dependent/Heading.t @@ -69,6 +69,9 @@ subtest "_search tests" => sub { t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); + # NOTE: We are testing solely against ES here to make the assumptions simpler while testing + # C4/Headings code specifically. The actual query building and searching code should + # be covered in other test files my $search = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search'); $search->mock('search_auth_compat', sub { --