View | Details | Raw Unified | Return to bug 27138
Collapse All | Expand All

(-)a/C4/Search.pm (-1 / +1 lines)
Lines 1755-1761 sub searchResults { Link Here
1755
        my $marcflavor = C4::Context->preference("marcflavour");
1755
        my $marcflavor = C4::Context->preference("marcflavour");
1756
1756
1757
        # adding linked items that belong to host records
1757
        # adding linked items that belong to host records
1758
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
1758
        if ( C4::Context->preference('EasyAnalyticalRecords') && !C4::Context->preference('EmbedHostItemsInSearchEngine') ) {
1759
            my $analyticsfield = '773';
1759
            my $analyticsfield = '773';
1760
            if ($marcflavor eq 'MARC21') {
1760
            if ($marcflavor eq 'MARC21') {
1761
                $analyticsfield = '773';
1761
                $analyticsfield = '773';
(-)a/C4/XSLT.pm (-1 / +2 lines)
Lines 326-332 Is only used in this module currently. Link Here
326
sub buildKohaItemsNamespace {
326
sub buildKohaItemsNamespace {
327
    my ($biblionumber, $hidden_items, $items_rs) = @_;
327
    my ($biblionumber, $hidden_items, $items_rs) = @_;
328
328
329
    my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber );
329
    my @host_itemnumbers = ();
330
    @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
330
    $hidden_items ||= [];
331
    $hidden_items ||= [];
331
332
332
    my $query = {};
333
    my $query = {};
(-)a/Koha/Biblio/Metadata.pm (-1 / +2 lines)
Lines 157-163 sub _embed_items { Link Here
157
            $record->delete_field($field);
157
            $record->delete_field($field);
158
        }
158
        }
159
159
160
        push @$itemnumbers, C4::Items::get_hostitemnumbers_of( $biblionumber ) if $params->{embed_host_items};
160
        push @$itemnumbers, C4::Items::get_hostitemnumbers_of( $biblionumber )
161
            if $params->{embed_host_items} && C4::Context->preference('EmbedHostItemsInSearchEngine');
161
162
162
        my $items = Koha::Items->search([
163
        my $items = Koha::Items->search([
163
           'me.biblionumber' => $biblionumber,
164
           'me.biblionumber' => $biblionumber,
(-)a/installer/data/mysql/atomicupdate/bug_27138_add_embedHostItems_syspref.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    # you can use $dbh here like:
4
    $dbh->do(q{
5
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
6
        ('EmbedHostItemsInSearchEngine','0','','Add host items to records in the search engine','YesNo');
7
    });
8
    NewVersion( $DBversion, 27138, "Add system preference EmbedHostItemsInSearchEngine");
9
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 205-210 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
205
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
205
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
206
('EmailOverduesNoEmail','1',NULL,'Send send overdues of patrons without email address to staff','YesNo'),
206
('EmailOverduesNoEmail','1',NULL,'Send send overdues of patrons without email address to staff','YesNo'),
207
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
207
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
208
('EmbedHostItemsInSearchEngine','0','','Add host items to records in the search engine','YesNo'),
208
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
209
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
209
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
210
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
210
('EnableExpiredPasswordReset', '0', NULL, 'Enable ability for patrons with expired password to reset their password directly', 'YesNo'),
211
('EnableExpiredPasswordReset', '0', NULL, 'Enable ability for patrons with expired password to reset their password directly', 'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+7 lines)
Lines 87-92 Searching: Link Here
87
                  0: Disable
87
                  0: Disable
88
            - "the cross_fields option for Elasticsearch searches, supported in Elasticsearch 6.X and above."
88
            - "the cross_fields option for Elasticsearch searches, supported in Elasticsearch 6.X and above."
89
            - "See documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields"
89
            - "See documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields"
90
        -
91
            - pref: EmbedHostItemsInSearchEngine
92
              default: 0
93
              choices:
94
                  1: Embed
95
                  0: Don't embed
96
            - 'host items in records in the search engine. Requires <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EasyAnalyticalRecords">EasyAnalyticalRecords</a>'
90
    Search form:
97
    Search form:
91
        -
98
        -
92
            - pref : LoadSearchHistoryToTheFirstLoggedUser
99
            - pref : LoadSearchHistoryToTheFirstLoggedUser
(-)a/misc/migration_tools/rebuild_zebra.pl (-6 / +3 lines)
Lines 511-517 sub export_marc_records_from_sth { Link Here
511
            if ($record_type eq 'biblio'){
511
            if ($record_type eq 'biblio'){
512
                my $biblio = Koha::Biblios->find($record_number);
512
                my $biblio = Koha::Biblios->find($record_number);
513
                next unless $biblio;
513
                next unless $biblio;
514
                my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $record_number );
514
                my @host_itemnumbers = ();
515
                @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $record_number ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
515
                my $items = Koha::Items->search({
516
                my $items = Koha::Items->search({
516
                    -or => [
517
                    -or => [
517
                        biblionumber => $record_number,
518
                        biblionumber => $record_number,
Lines 689-702 sub get_raw_marc_record { Link Here
689
690
690
    my $marc;
691
    my $marc;
691
    if ($record_type eq 'biblio') {
692
    if ($record_type eq 'biblio') {
692
<<<<<<< HEAD
693
        eval {
693
        eval {
694
            my $biblio = Koha::Biblios->find($record_number);
694
            my $biblio = Koha::Biblios->find($record_number);
695
            $marc = $biblio->metadata->record({ embed_items => 1 });
695
            $marc = $biblio->metadata->record({ embed_items => 1, embed_host_items => 1 });
696
        };
696
        };
697
=======
698
        eval { $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $record_number, embed_items => 1, embed_host_items => 1 }); };
699
>>>>>>> Bug 27138: Index host items in child records when sending to search engine
700
        if ($@ || !$marc) {
697
        if ($@ || !$marc) {
701
            # here we do warn since catching an exception
698
            # here we do warn since catching an exception
702
            # means that the bib was found but failed
699
            # means that the bib was found but failed
(-)a/t/db_dependent/Items.t (-3 / +17 lines)
Lines 666-672 subtest 'Koha::Item(s) tests' => sub { Link Here
666
};
666
};
667
667
668
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
668
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
669
    plan tests => 11;
669
    plan tests => 12;
670
670
671
    $schema->storage->txn_begin();
671
    $schema->storage->txn_begin();
672
672
Lines 710-715 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
710
        push @itemnumbers, $itemnumber;
710
        push @itemnumbers, $itemnumber;
711
    }
711
    }
712
712
713
    t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', '1' );
713
    my $host_item = $builder->build_sample_item({ homebranch => $library2->{branchcode} });
714
    my $host_item = $builder->build_sample_item({ homebranch => $library2->{branchcode} });
714
    my $child_field = PrepHostMarcField( $host_item->biblionumber, $host_item->itemnumber, 'MARC21');
715
    my $child_field = PrepHostMarcField( $host_item->biblionumber, $host_item->itemnumber, 'MARC21');
715
    my $child_record = $biblio->metadata->record;
716
    my $child_record = $biblio->metadata->record;
Lines 745-756 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
745
    @items = $record->field($itemfield);
746
    @items = $record->field($itemfield);
746
    is( scalar @items, $number_of_items + 1, 'Should return all items plus host items' );
747
    is( scalar @items, $number_of_items + 1, 'Should return all items plus host items' );
747
748
749
    t::lib::Mocks::mock_preference('EmbedHostItemsInSearchEngine', '1');
748
    $marc_with_items = C4::Biblio::GetMarcBiblio({
750
    $marc_with_items = C4::Biblio::GetMarcBiblio({
749
        biblionumber => $biblio->biblionumber,
751
        biblionumber => $biblio->biblionumber,
750
        embed_items  => 1,
752
        embed_items  => 1,
751
        embed_host_items => 1
753
        embed_host_items => 1
752
    });
754
    });
753
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with items matches');
755
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with embed host items matches if embedding items in search engine');
756
    $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber });
757
    C4::Biblio::EmbedItemsInMarcBiblio({
758
        marc_record  => $record,
759
        biblionumber => $biblio->biblionumber,
760
        embed_host_items => 0
761
    });
762
    t::lib::Mocks::mock_preference('EmbedHostItemsInSearchEngine', '0');
763
    $marc_with_items = C4::Biblio::GetMarcBiblio({
764
        biblionumber => $biblio->biblionumber,
765
        embed_items  => 1,
766
        embed_host_items => 1
767
    });
768
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with embed host items does not include host item if not embedding items in search engine');
754
769
755
    C4::Biblio::EmbedItemsInMarcBiblio({
770
    C4::Biblio::EmbedItemsInMarcBiblio({
756
        marc_record  => $record,
771
        marc_record  => $record,
757
- 

Return to bug 27138