From 824d63b7d5c95bf21fcb93f37516511c5b55a464 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 21 Mar 2023 19:34:50 +0000 Subject: [PATCH] Bug 33277: Search thesaurus for 'notspecified' Content-Type: text/plain; charset=utf-8 Signed-off-by: Frank Hansen Signed-off-by: Marcel de Rooy --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 6 ++++-- .../marc21/authorities/authority-zebra-indexdefs.xsl | 2 +- t/db_dependent/Heading.t | 12 +++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 587f86e648..3237bbc5e8 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -573,11 +573,13 @@ our $thesaurus_to_value = { lcac => 'b', mesh => 'c', nal => 'd', - notspecified => 'n', + notapplicable => 'n', cash => 'k', rvm => 'v', aat => 'r', - sears => 's' + sears => 's', + notdefined => 'z', + notspecified => '|' }; sub build_authorities_query_compat { diff --git a/etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl index 0723caf2b4..b38e0f0cd0 100644 --- a/etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl +++ b/etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl @@ -2452,7 +2452,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) - notdefined + notspecified diff --git a/t/db_dependent/Heading.t b/t/db_dependent/Heading.t index 26c4d8da28..d65132dbc9 100755 --- a/t/db_dependent/Heading.t +++ b/t/db_dependent/Heading.t @@ -65,7 +65,7 @@ subtest "UNIMARC tests" => sub { subtest "_search tests" => sub { - plan tests => 7; + plan tests => 8; t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); @@ -111,6 +111,16 @@ subtest "_search tests" => sub { ]; is_deeply( $terms, $expected_terms, "Search formed as expected with second indicator 7 and subfield 2"); + $field = MARC::Field->new( '650', ' ', '4', a => 'Uncles', x => 'Fiction' ); + $heading = C4::Heading->new_from_field($field); + ($search_query) = $heading->_search( 'match-heading' ); + $terms = $search_query->{query}->{bool}->{must}; + $expected_terms = [ + { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, + { term => { 'subject-heading-thesaurus.ci_raw' => '|' } }, + ]; + is_deeply( $terms, $expected_terms, "Search looks for thesaurus '|' when second indicator 4"); + $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,' ); $heading = C4::Heading->new_from_field($field); ($search_query) = $heading->_search( 'match-heading' ); -- 2.30.2