From eefef42abda81e84e42d4a3951684092045886fa Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 20 Aug 2014 00:48:07 -0300 Subject: [PATCH] Bug 12788: facets calculation should skip 100 if ind1=z This patch adds a test for field 100, to skip it on facet calculation if ind1=z. To test: - Have IncludeSeeFromInSearches set. - Create a biblio record, when adding an author, create a new authority record that contains a 400$a field (see from). - Rebuild zebra db. - Search for the record making sure the search returns more than one record. => FAIL: the facets contain the 'see from' field. - Run $ prove -v t/db_dependent/Search.t => FAIL: it fails - Apply the patch - Run $ prove -v t/db_dependent/Search.t => SUCCESS: it passes - Re-run the search, notice the 'see from' doesn't show anymore on the facets. - Sign off :-D Edit: minor stylistic change Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Nick Clemens Signed-off-by: David Cook Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/Search.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index e90ecc9774..54ef9eceab 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -656,7 +656,7 @@ sub getRecords { C4::Search::_get_facets_data_from_record( $marc_record, $facets, $facets_counter ); Internal function that extracts facets information from a MARC::Record object -and populates $facets_counter for using in getRecords. +and populates $facets_counter and $facets_info for using in getRecords. $facets is expected to be filled with C4::Koha::getFacets output (i.e. the configured facets for Zebra). @@ -673,14 +673,17 @@ sub _get_facets_data_from_record { foreach my $tag ( @{ $facet->{ tags } } ) { - # avoid first line + # tag number is the first three digits my $tag_num = substr( $tag, 0, 3 ); + # subfields are the remainder my $subfield_letters = substr( $tag, 3 ); - # Removed when as_string fixed - my @subfields = $subfield_letters =~ /./sg; my @fields = $marc_record->field( $tag_num ); foreach my $field (@fields) { + # If $field->indicator(1) eq 'z', it means it is a 'see from' + # field introduced because of IncludeSeeFromInSearches, so skip it + next if $field->indicator(1) eq 'z'; + my $data = $field->as_string( $subfield_letters, $facet->{ sep } ); unless ( grep { /^\Q$data\E$/ } @used_datas ) { -- 2.39.5