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

(-)a/C4/Heading.pm (-2 / +5 lines)
Lines 202-207 sub _search { Link Here
202
    my @operator;
202
    my @operator;
203
    my @value;
203
    my @value;
204
204
205
    my $check_thesaurus = C4::Context->preference('LinkerConsiderThesaurus');
206
205
    # FIXME: We specify values for @and_or and @excluding
207
    # FIXME: We specify values for @and_or and @excluding
206
    # but these fields are not used anywhere and should be removed
208
    # but these fields are not used anywhere and should be removed
207
    if ($index) {
209
    if ($index) {
Lines 211-217 sub _search { Link Here
211
        push @value,    $self->{'search_form'};
213
        push @value,    $self->{'search_form'};
212
    }
214
    }
213
215
214
    if ( $thesaurus ) {
216
    if ( $check_thesaurus && $thesaurus ) {
215
        push @marclist, 'thesaurus';
217
        push @marclist, 'thesaurus';
216
        push @and_or, 'and';
218
        push @and_or, 'and';
217
        push @excluding, '';
219
        push @excluding, '';
Lines 240-246 sub _search { Link Here
240
    # Some auth records may not contain the 040$f to specify their source
242
    # Some auth records may not contain the 040$f to specify their source
241
    # This is legal, so we do a fallback search
243
    # This is legal, so we do a fallback search
242
    if (
244
    if (
243
          !$total
245
           $check_thesaurus
246
        && !$total
244
        && $thesaurus
247
        && $thesaurus
245
        && none { $_ eq $thesaurus } (
248
        && none { $_ eq $thesaurus } (
246
            'lcsh',         'lcac', 'mesh', 'nal',
249
            'lcsh',         'lcac', 'mesh', 'nal',
(-)a/installer/data/mysql/atomicupdate/bug_33557.pl (+15 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "33557",
5
    description => "Add a system preference LinkerConsiderThesaurus",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        $dbh->do(q{
10
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
11
            ('LinkerConsiderThesaurus','0',NULL,'If ON the authority linker will only search for 6XX authorities from the same source as the heading','YesNo')
12
        });
13
        say $out "Added new system preference 'LinkerConsiderThesaurus'";
14
    },
15
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 343-348 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
343
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
343
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
344
('LibrisKey', '', 'This key must be obtained at http://api.libris.kb.se/. It is unique for the IP of the server.', NULL, 'Free'),
344
('LibrisKey', '', 'This key must be obtained at http://api.libris.kb.se/. It is unique for the IP of the server.', NULL, 'Free'),
345
('LibrisURL', 'http://api.libris.kb.se/bibspell/', 'This it the base URL for the Libris spellchecking API.',NULL,'Free'),
345
('LibrisURL', 'http://api.libris.kb.se/bibspell/', 'This it the base URL for the Libris spellchecking API.',NULL,'Free'),
346
('LinkerConsiderThesaurus','0',NULL,'If ON the authority linker will only search for 6XX authorities from the same source as the heading','YesNo'),
346
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
347
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
347
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
348
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
348
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
349
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref (+7 lines)
Lines 119-121 Authorities: Link Here
119
                  1: Do
119
                  1: Do
120
                  0: "Don't"
120
                  0: "Don't"
121
            - attempt to automatically link headings when saving records in the cataloging module, obeys <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=LinkerRelink'>LinkerRelink</a> and <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CatalogModuleRelink'>CatalogModuleRelink</a> for record edits.
121
            - attempt to automatically link headings when saving records in the cataloging module, obeys <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=LinkerRelink'>LinkerRelink</a> and <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CatalogModuleRelink'>CatalogModuleRelink</a> for record edits.
122
        -
123
            - pref: LinkerConsiderThesaurus
124
              default: no
125
              choices:
126
                  1: Do
127
                  0: "Don't"
128
            - compare the source for 6XX headings to the thesaurus source for authority records when linking. Enabling this preference may require a reindex, and may generate new authority records if AutoCreateAuthorities is enabled.
(-)a/t/db_dependent/Heading.t (-3 / +28 lines)
Lines 65-71 subtest "UNIMARC tests" => sub { Link Here
65
65
66
subtest "_search tests" => sub {
66
subtest "_search tests" => sub {
67
67
68
    plan tests => 8;
68
    plan tests => 10;
69
69
70
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
70
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
71
    t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch');
71
    t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch');
Lines 80-85 subtest "_search tests" => sub { Link Here
80
        return ($search_query, 1 );
80
        return ($search_query, 1 );
81
    });
81
    });
82
82
83
    t::lib::Mocks::mock_preference('LinkerConsiderThesaurus', '0');
83
84
84
    my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
85
    my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
85
    my $heading = C4::Heading->new_from_field($field);
86
    my $heading = C4::Heading->new_from_field($field);
Lines 87-92 subtest "_search tests" => sub { Link Here
87
    my $terms = $search_query->{query}->{bool}->{must};
88
    my $terms = $search_query->{query}->{bool}->{must};
88
    my $expected_terms = [
89
    my $expected_terms = [
89
        { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } },
90
        { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } },
91
    ];
92
    is_deeply( $terms, $expected_terms, "Search formed only using heading content, not thesaurus, when LinkerConsiderThesaurus disabled");
93
94
95
    t::lib::Mocks::mock_preference('LinkerConsiderThesaurus', '1');
96
97
    $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
98
    $heading = C4::Heading->new_from_field($field);
99
    ($search_query) = $heading->_search( 'match-heading' );
100
    $terms = $search_query->{query}->{bool}->{must};
101
    $expected_terms = [
102
        { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } },
90
        { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } },
103
        { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } },
91
    ];
104
    ];
92
    is_deeply( $terms, $expected_terms, "Search formed as expected for a subject with second indicator 0");
105
    is_deeply( $terms, $expected_terms, "Search formed as expected for a subject with second indicator 0");
Lines 151-157 subtest "_search tests" => sub { Link Here
151
    $search->mock('search_auth_compat', sub {
164
    $search->mock('search_auth_compat', sub {
152
        my $self = shift;
165
        my $self = shift;
153
        my $search_query = shift;
166
        my $search_query = shift;
154
        if( $search_query->{query}->{bool}->{must}[1]->{term}->{'subject-heading-thesaurus.ci_raw'} eq 'special_sauce' ){
167
        if(
168
            scalar @{$search_query->{query}->{bool}->{must}} == 2 &&
169
            $search_query->{query}->{bool}->{must}[1]->{term}->{'subject-heading-thesaurus.ci_raw'} eq 'special_sauce'
170
        ){
155
            return;
171
            return;
156
        }
172
        }
157
        return ($search_query, 1);
173
        return ($search_query, 1);
Lines 168-171 subtest "_search tests" => sub { Link Here
168
    ];
184
    ];
169
    is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we should search again for notdefined (008_11 = z) ");
185
    is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we should search again for notdefined (008_11 = z) ");
170
186
187
    t::lib::Mocks::mock_preference('LinkerConsiderThesaurus', '0');
188
189
    $search_query = undef;
190
    ($search_query) = $heading->_search( 'match-heading' );
191
    $terms = $search_query->{query}->{bool}->{must};
192
    $expected_terms = [
193
        { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } },
194
    ];
195
    is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled");
196
171
};
197
};
172
- 

Return to bug 33557