@@ -, +, @@ --- C4/Heading.pm | 5 ++++- t/db_dependent/Heading.t | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) --- a/C4/Heading.pm +++ a/C4/Heading.pm @@ -211,7 +211,10 @@ sub _search { push @value, $self->{'search_form'}; } - if ( $thesaurus ) { + # FIXME we don't have a method for negative search + # but 'notspecified' should be 'not n' - the best + # we can achieve currently is to ignore the thesaurus + if ( $thesaurus && $thesaurus ne 'notspecified' ) { push @marclist, 'thesaurus'; push @and_or, 'and'; push @excluding, ''; --- a/t/db_dependent/Heading.t +++ a/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,15 @@ 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' } }, + ]; + is_deeply( $terms, $expected_terms, "Search doesn't specify thesaurus when heading marked as 'notspecified'"); + $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,' ); $heading = C4::Heading->new_from_field($field); ($search_query) = $heading->_search( 'match-heading' ); --