diff --git a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm b/Koha/Filter/MARC/EmbedSeeFromHeadings.pm
index 9973db90de..93eaf44501 100644
--- a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm
+++ b/Koha/Filter/MARC/EmbedSeeFromHeadings.pm
@@ -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,
diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm
index 531d410e5b..b7359f5f47 100644
--- a/Koha/SearchEngine/Elasticsearch.pm
+++ b/Koha/SearchEngine/Elasticsearch.pm
@@ -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};
diff --git a/installer/data/mysql/atomicupdate/bug_34481.pl b/installer/data/mysql/atomicupdate/bug_34481.pl
new file mode 100755
index 0000000000..e7a4f01038
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_34481.pl
@@ -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'";
+ },
+};
diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql
index 164a26f040..0496d3fd48 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -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'),
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
index da202d7e1e..c5188c5742 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
@@ -65,7 +65,14 @@ Searching:
choices:
1: Include
0: "Don't include"
- - "see from (non-preferred form) headings in bibliographic searches. Please note: you will need to reindex your bibliographic database when changing this preference."
+ - "see from (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"
+ - "see also from headings in bibliographic searches. Please note: you will need to reindex your bibliographic database when changing this preference."
-
- pref: EnableSearchHistory
default: 0
diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl
index ec19ce1f5c..941c5f8e2f 100755
--- a/misc/migration_tools/rebuild_zebra.pl
+++ b/misc/migration_tools/rebuild_zebra.pl
@@ -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" ) {