Bug 34481: Add IncludeSeeAlsoFromInSearches like IncludeSeeFromInSearches
Like IncludeSeeFromInSearches adds see from heading in search (4xx), new system preference IncludeSeeAlsoFromInSearches adds see also from heading (5xx). Test plan: Test on both Elasticsearch and Zebra: 1) 1.1) Create an authority record with heading, see from heading 4xx and see also from heading 5xx 1.2) Use this authority in a biblio record 2) 2.1) Set IncludeSeeFromInSearches and IncludeSeeAlsoFromInSearches to "Don't include" 2.3) Rebuild search engine 2.4) Perform a search on heading text => you find the biblio record 2.5) Perform a search on see from heading => you do not find the biblio record 2.6) Perform a search on see also from heading => you do not find the biblio record 3) 3.1) Set IncludeSeeFromInSearches and IncludeSeeAlsoFromInSearches to "Include" 3.2) Rebuild search engine 3.3) Perform a search on heading text => you find the biblio record 3.4) Perform a search on see from heading => you find the biblio record 3.5) Perform a search on see also from heading => you find the biblio record Signed-off-by: Frédéric Demians <f.demians@tamil.fr> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
0877dfd16d
commit
cb085034ff
|
|
@ -88,6 +88,19 @@ include in facets, sorting, or suggestion fields)
|
|||
sub fields {
|
||||
my ($self, $record) = @_;
|
||||
|
||||
my $params = $self->params;
|
||||
my $other_headings = $params->{options}->{other_headings} || [ 'see_from' ];
|
||||
|
||||
my @auth_others;
|
||||
foreach my $other_heading ( @$other_headings ) {
|
||||
if ( $other_heading eq 'see_from' ) {
|
||||
push @auth_others, '4..';
|
||||
}
|
||||
if ( $other_heading eq 'see_also_from' ) {
|
||||
push @auth_others, '5..';
|
||||
}
|
||||
}
|
||||
|
||||
my ($item_tag) = GetMarcFromKohaField( "items.itemnumber" );
|
||||
$item_tag ||= '';
|
||||
|
||||
|
|
@ -102,8 +115,8 @@ sub fields {
|
|||
my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
|
||||
next unless $authority;
|
||||
my $auth_marc = $authority->record;
|
||||
my @seefrom = $auth_marc->field('4..');
|
||||
foreach my $authfield (@seefrom) {
|
||||
my @authfields = $auth_marc->field(@auth_others);
|
||||
foreach my $authfield (@authfields) {
|
||||
my $tag = substr($field->tag(), 0, 1) . substr($authfield->tag(), 1, 2);
|
||||
next if MARC::Field->is_controlfield_tag($tag);
|
||||
my $newfield = MARC::Field->new($tag,
|
||||
|
|
|
|||
|
|
@ -664,8 +664,23 @@ sub marc_records_to_documents {
|
|||
}
|
||||
}
|
||||
|
||||
if (C4::Context->preference('IncludeSeeFromInSearches') and $self->index eq 'biblios') {
|
||||
foreach my $field (Koha::Filter::MARC::EmbedSeeFromHeadings->new->fields($record)) {
|
||||
if ( $self->index eq $BIBLIOS_INDEX and ( C4::Context->preference('IncludeSeeFromInSearches') || C4::Context->preference('IncludeSeeAlsoFromInSearches') ) ) {
|
||||
my $marc_filter = Koha::Filter::MARC::EmbedSeeFromHeadings->new;
|
||||
my @other_headings;
|
||||
if ( C4::Context->preference('IncludeSeeFromInSearches') ) {
|
||||
push @other_headings, 'see_from';
|
||||
}
|
||||
if ( C4::Context->preference('IncludeSeeAlsoFromInSearches') ) {
|
||||
push @other_headings, 'see_also_from';
|
||||
}
|
||||
$marc_filter->initialize(
|
||||
{
|
||||
options => {
|
||||
other_headings => \@other_headings
|
||||
}
|
||||
}
|
||||
);
|
||||
foreach my $field ($marc_filter->fields($record)) {
|
||||
my $data_field_rules = $data_fields_rules->{$field->tag()};
|
||||
if ($data_field_rules) {
|
||||
my $subfields_mappings = $data_field_rules->{subfields};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
use Modern::Perl;
|
||||
|
||||
return {
|
||||
bug_number => "34481",
|
||||
description => "Add IncludeSeeAlsoFromInSearches like IncludeSeeFromInSearches",
|
||||
up => sub {
|
||||
my ($args) = @_;
|
||||
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||
|
||||
$dbh->do(q{
|
||||
INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`)
|
||||
VALUES ('IncludeSeeAlsoFromInSearches','0','','Include see-also-from references in searches.','YesNo')
|
||||
});
|
||||
|
||||
say $out "Added new system preference 'IncludeSeeAlsoFromInSearches'";
|
||||
},
|
||||
};
|
||||
|
|
@ -325,6 +325,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
|
|||
('ILS-DI','0','','Enables ILS-DI services at OPAC.','YesNo'),
|
||||
('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'),
|
||||
('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'),
|
||||
('IncludeSeeAlsoFromInSearches','0','','Include see-also-from references in searches.','YesNo'),
|
||||
('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo'),
|
||||
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
|
||||
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
|
||||
|
|
|
|||
|
|
@ -65,7 +65,14 @@ Searching:
|
|||
choices:
|
||||
1: Include
|
||||
0: "Don't include"
|
||||
- "<em>see from</em> (non-preferred form) headings in bibliographic searches. Please note: you will need to reindex your bibliographic database when changing this preference."
|
||||
- "<em>see from</em> (non-preferred form) headings in bibliographic searches. Please note: you will need to reindex your bibliographic database when changing this system preference."
|
||||
-
|
||||
- pref: IncludeSeeAlsoFromInSearches
|
||||
default: 0
|
||||
choices:
|
||||
1: Include
|
||||
0: "Don't include"
|
||||
- "<em>see also from</em> headings in bibliographic searches. Please note: you will need to reindex your bibliographic database when changing this preference."
|
||||
-
|
||||
- pref: EnableSearchHistory
|
||||
default: 0
|
||||
|
|
|
|||
|
|
@ -660,11 +660,26 @@ sub get_corrected_marc_record {
|
|||
elsif ( $record_type eq 'biblio' ) {
|
||||
|
||||
my @filters;
|
||||
my @other_headings;
|
||||
push @filters, 'EmbedItemsAvailability';
|
||||
push @filters, 'EmbedSeeFromHeadings'
|
||||
if C4::Context->preference('IncludeSeeFromInSearches');
|
||||
if ( C4::Context->preference('IncludeSeeFromInSearches') || C4::Context->preference('IncludeSeeAlsoFromInSearches') ){
|
||||
push @filters, 'EmbedSeeFromHeadings';
|
||||
if ( C4::Context->preference('IncludeSeeFromInSearches') ) {
|
||||
push @other_headings, 'see_from';
|
||||
}
|
||||
if ( C4::Context->preference('IncludeSeeAlsoFromInSearches') ) {
|
||||
push @other_headings, 'see_also_from';
|
||||
}
|
||||
}
|
||||
|
||||
my $normalizer = Koha::RecordProcessor->new( { filters => \@filters } );
|
||||
my $normalizer = Koha::RecordProcessor->new(
|
||||
{
|
||||
filters => \@filters,
|
||||
options => {
|
||||
other_headings => \@other_headings
|
||||
}
|
||||
}
|
||||
);
|
||||
$marc = $normalizer->process($marc);
|
||||
}
|
||||
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue