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

(-)a/C4/Heading.pm (-29 / +21 lines)
Lines 194-201 sub _search { Link Here
194
    my $self         = shift;
194
    my $self         = shift;
195
    my $index        = shift || undef;
195
    my $index        = shift || undef;
196
    my $skipmetadata = shift || undef;
196
    my $skipmetadata = shift || undef;
197
    my $ind2         = $self->{field}->{_ind2};
197
    my $ind2         = $self->{field}->indicator('2');
198
    my $subject_heading_thesaurus = '';
199
    my @marclist;
198
    my @marclist;
200
    my @and_or;
199
    my @and_or;
201
    my @excluding = [];
200
    my @excluding = [];
Lines 209-244 sub _search { Link Here
209
        push @value,    $self->{'search_form'};
208
        push @value,    $self->{'search_form'};
210
    }
209
    }
211
210
212
    if ($self->{'thesaurus'}) {
211
    if (C4::Context->preference("LinkerStrictAuthInfo") && $self->{'thesaurus'}) {
213
        if ($ind2 eq '0') {
214
            $subject_heading_thesaurus = 'a';
215
        } elsif ($ind2 eq '1') {
216
            $subject_heading_thesaurus = 'b';
217
        } elsif ($ind2 eq '2') {
218
            $subject_heading_thesaurus = 'c';
219
        } elsif ($ind2 eq '3') {
220
            $subject_heading_thesaurus = 'd';
221
        } elsif ($ind2 eq '4') {
222
            $subject_heading_thesaurus = 'n';
223
        } elsif ($ind2 eq '5') {
224
            $subject_heading_thesaurus = 'k';
225
        } elsif ($ind2 eq '6') {
226
            $subject_heading_thesaurus = 'v';
227
        } else {
228
            $subject_heading_thesaurus = 'z';
229
        }
230
        push @marclist, 'thesaurus';
212
        push @marclist, 'thesaurus';
231
        push @and_or, 'and';
213
        push @and_or, 'and';
232
        push @excluding, '';
214
        push @excluding, '';
233
        push @operator, 'is';
215
        push @operator, 'is';
234
        push @value, $subject_heading_thesaurus;
235
    }
236
237
    if ($ind2 eq '7') {
238
        push @marclist, 'thesaurus-conventions';
239
        push @and_or, 'and';
240
        push @excluding, '';
241
        push @operator, 'is';
242
        push @value, $self->{'thesaurus'};
216
        push @value, $self->{'thesaurus'};
243
    }
217
    }
244
218
Lines 258-264 sub _search { Link Here
258
        \@value,    $self->{'auth_type'},
232
        \@value,    $self->{'auth_type'},
259
        'AuthidAsc'
233
        'AuthidAsc'
260
    );
234
    );
261
    return $searcher->search_auth_compat( $search_query, 0, 20, $skipmetadata );
235
    my ( $authresults, $total ) = $searcher->search_auth_compat( $search_query, 0, 20, $skipmetadata );
236
    if (C4::Context->preference("LinkerStrictAuthInfo") && ! $total && $ind2 eq '7') {
237
        for (my $i = $#value; $i >= 0; $i--) {
238
            # For the case when auth 008/11 was 'z', but thesaurus was not declared in 040 $f
239
            # (which is legal in MARC 21) we try to search again with 'other' (that stands
240
            # for 008/11 = 'z') instead of biblio 6XX $7 (i.e. $self->{'thesaurus'})
241
            if ($value[$i] eq $self->{'thesaurus'} && $self->{'thesaurus'} ne 'notdefined') {
242
                $value[$i] = 'notdefined';
243
                $search_query = $builder->build_authorities_query_compat(
244
                    \@marclist, \@and_or, \@excluding, \@operator,
245
                    \@value,    $self->{'auth_type'},
246
                    'AuthidAsc'
247
                );
248
                ( $authresults, $total ) = $searcher->search_auth_compat( $search_query, 0, 20, $skipmetadata );
249
                last;
250
            }
251
        }
252
    }
253
    return ( $authresults, $total );
262
}
254
}
263
255
264
=head1 INTERNAL FUNCTIONS
256
=head1 INTERNAL FUNCTIONS
(-)a/C4/Heading/MARC21.pm (-2 / +2 lines)
Lines 339-345 sub parse_heading { Link Here
339
    my $thesaurus =
339
    my $thesaurus =
340
      $tag =~ m/6../
340
      $tag =~ m/6../
341
      ? _get_subject_thesaurus($field)
341
      ? _get_subject_thesaurus($field)
342
      : "lcsh";    # use 'lcsh' for names, UT, etc.
342
      : undef;    # defining thesaurus makes sence only for 6XX
343
    my $search_heading =
343
    my $search_heading =
344
      _get_search_heading( $field, $field_info->{'subfields'} );
344
      _get_search_heading( $field, $field_info->{'subfields'} );
345
    my $display_heading =
345
    my $display_heading =
Lines 383-389 sub _get_subject_thesaurus { Link Here
383
    }
383
    }
384
    elsif ( $ind2 eq '7' ) {
384
    elsif ( $ind2 eq '7' ) {
385
        my $sf2 = $field->subfield('2');
385
        my $sf2 = $field->subfield('2');
386
        $thesaurus = $sf2 if defined($sf2);
386
        $thesaurus = $sf2 ? $sf2 : 'notdefined';
387
    }
387
    }
388
388
389
    return $thesaurus;
389
    return $thesaurus;
(-)a/Koha/SearchEngine/Elasticsearch.pm (+2 lines)
Lines 212-217 sub get_elasticsearch_mappings { Link Here
212
                    $es_type = 'year';
212
                    $es_type = 'year';
213
                } elsif ($type eq 'callnumber') {
213
                } elsif ($type eq 'callnumber') {
214
                    $es_type = 'cn_sort';
214
                    $es_type = 'cn_sort';
215
                } elsif ($type eq 'thesaurus') {
216
                    $es_type = 'thesaurus';
215
                }
217
                }
216
218
217
                if ($search) {
219
                if ($search) {
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 lines)
Lines 559-565 our $koha_to_index_name = { Link Here
559
    'match-heading' => 'match-heading',
559
    'match-heading' => 'match-heading',
560
    'see-from'      => 'match-heading-see-from',
560
    'see-from'      => 'match-heading-see-from',
561
    thesaurus       => 'subject-heading-thesaurus',
561
    thesaurus       => 'subject-heading-thesaurus',
562
    'thesaurus-conventions' => 'subject-heading-thesaurus-conventions',
563
    any             => '',
562
    any             => '',
564
    all             => ''
563
    all             => ''
565
};
564
};
(-)a/admin/searchengine/elasticsearch/field_config.yaml (+13 lines)
Lines 38-43 search: Link Here
38
        search_analyzer: analyzer_phrase
38
        search_analyzer: analyzer_phrase
39
      raw:
39
      raw:
40
        type: keyword
40
        type: keyword
41
  thesaurus:
42
    type: text
43
    analyzer: analyzer_thesaurus
44
    search_analyzer: analyzer_thesaurus
45
    fields:
46
      raw:
47
        type: text
48
        analyzer: analyzer_thesaurus
49
        search_analyzer: analyzer_thesaurus
50
      ci_raw:
51
        type: text
52
        analyzer: analyzer_thesaurus
53
        search_analyzer: analyzer_thesaurus
41
  default:
54
  default:
42
    type: text
55
    type: text
43
    analyzer: analyzer_standard
56
    analyzer: analyzer_standard
(-)a/admin/searchengine/elasticsearch/index_config.yaml (+19 lines)
Lines 20-25 index: Link Here
20
          - icu_folding
20
          - icu_folding
21
        char_filter:
21
        char_filter:
22
          - punctuation
22
          - punctuation
23
      analyzer_thesaurus:
24
        tokenizer: keyword
25
        filter:
26
          - thesaurus
23
    normalizer:
27
    normalizer:
24
      icu_folding_normalizer:
28
      icu_folding_normalizer:
25
        type: custom
29
        type: custom
Lines 41-46 index: Link Here
41
        type: pattern_replace
45
        type: pattern_replace
42
        pattern: '\s*(?<!\p{Lu})[.\-,;]*\s*$'
46
        pattern: '\s*(?<!\p{Lu})[.\-,;]*\s*$'
43
        replacement: ''
47
        replacement: ''
48
    filter:
49
      thesaurus:
50
        type: synonym
51
        synonyms:
52
          - a => lcsh
53
          - b => lcac
54
          - c => mesh
55
          - d => nal
56
          - k => cash
57
          - n => notapplicable
58
          - r => aat
59
          - s => sears
60
          - v => rvm
61
          - z => notdefined
62
          - "| => notspecified"
44
index.mapping.total_fields.limit: 10000
63
index.mapping.total_fields.limit: 10000
45
index.max_result_window: 1000000
64
index.max_result_window: 1000000
46
index.number_of_replicas: 1
65
index.number_of_replicas: 1
(-)a/admin/searchengine/elasticsearch/mappings.yaml (-5 / +1 lines)
Lines 813-828 authorities: Link Here
813
        marc_type: marc21
813
        marc_type: marc21
814
        sort: ~
814
        sort: ~
815
        suggestible: ''
815
        suggestible: ''
816
    type: ''
817
  Subject-heading-thesaurus-conventions:
818
    label: Subject-heading-thesaurus-conventions
819
    mappings:
820
      - facet: ''
816
      - facet: ''
821
        marc_field: 040f
817
        marc_field: 040f
822
        marc_type: marc21
818
        marc_type: marc21
823
        sort: ~
819
        sort: ~
824
        suggestible: ''
820
        suggestible: ''
825
    type: ''
821
    type: thesaurus
826
  authtype:
822
  authtype:
827
    label: authtype
823
    label: authtype
828
    mappings:
824
    mappings:
(-)a/etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl (+3 lines)
Lines 2441-2446 definition file (probably something like {biblio,authority}-koha-indexdefs.xml) Link Here
2441
        <xslo:when test="$thesaurus_code1 = 'v'">
2441
        <xslo:when test="$thesaurus_code1 = 'v'">
2442
          <xslo:text>rvm</xslo:text>
2442
          <xslo:text>rvm</xslo:text>
2443
        </xslo:when>
2443
        </xslo:when>
2444
        <xslo:when test="$thesaurus_code1 = '|'">
2445
          <xslo:text>notspecified</xslo:text>
2446
        </xslo:when>
2444
        <xslo:when test="$thesaurus_code1 = 'z'">
2447
        <xslo:when test="$thesaurus_code1 = 'z'">
2445
          <xslo:choose>
2448
          <xslo:choose>
2446
            <xslo:when test="//marc:datafield[@tag='040']/marc:subfield[@code='f']">
2449
            <xslo:when test="//marc:datafield[@tag='040']/marc:subfield[@code='f']">
(-)a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl (+1 lines)
Lines 158-163 definition file (probably something like {biblio,authority}-koha-indexdefs.xml) Link Here
158
                    <xslo:when test="$thesaurus_code1 = 'r'"><xslo:text>aat</xslo:text></xslo:when>
158
                    <xslo:when test="$thesaurus_code1 = 'r'"><xslo:text>aat</xslo:text></xslo:when>
159
                    <xslo:when test="$thesaurus_code1 = 's'"><xslo:text>sears</xslo:text></xslo:when>
159
                    <xslo:when test="$thesaurus_code1 = 's'"><xslo:text>sears</xslo:text></xslo:when>
160
                    <xslo:when test="$thesaurus_code1 = 'v'"><xslo:text>rvm</xslo:text></xslo:when>
160
                    <xslo:when test="$thesaurus_code1 = 'v'"><xslo:text>rvm</xslo:text></xslo:when>
161
                    <xslo:when test="$thesaurus_code1 = '|'"><xslo:text>notspecified</xslo:text></xslo:when>
161
                    <xslo:when test="$thesaurus_code1 = 'z'">
162
                    <xslo:when test="$thesaurus_code1 = 'z'">
162
                        <xslo:choose>
163
                        <xslo:choose>
163
                            <xslo:when>
164
                            <xslo:when>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (-1 / +5 lines)
Lines 227-232 a.add, a.delete { Link Here
227
                                    [% ELSE %]
227
                                    [% ELSE %]
228
                                        <option value="callnumber">Call Number</option>
228
                                        <option value="callnumber">Call Number</option>
229
                                    [% END %]
229
                                    [% END %]
230
                                    [% IF search_field.type == "thesaurus" %]
231
                                        <option value="thesaurus" selected="selected">Thesaurus</option>
232
                                    [% ELSE %]
233
                                        <option value="thesaurus">Thesaurus</option>
234
                                    [% END %]
230
                                    </select>
235
                                    </select>
231
                            </td>
236
                            </td>
232
                                <td data-order="[% search_field.weight | html %]">
237
                                <td data-order="[% search_field.weight | html %]">
233
- 

Return to bug 32916