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

(-)a/C4/AuthoritiesMarc.pm (-1 / +4 lines)
Lines 175-181 sub SearchAuthorities { Link Here
175
            }
175
            }
176
176
177
            my $operator = @$operator[$i];
177
            my $operator = @$operator[$i];
178
            if ( $operator and $operator eq 'is' ) {
178
            if ( @$tags[$i] eq "thesaurus" ) {
179
                $attr .= " \@attr 4=3 "
180
            }
181
            elsif ( $operator and $operator eq 'is' ) {
179
                $attr .= " \@attr 4=1  \@attr 5=100 "
182
                $attr .= " \@attr 4=1  \@attr 5=100 "
180
                  ;    ##Phrase, No truncation,all of subfield field must match
183
                  ;    ##Phrase, No truncation,all of subfield field must match
181
            }
184
            }
(-)a/C4/Heading.pm (-29 / +25 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") && $self->{'thesaurus'} && ! $total && $ind2 eq '7') {
237
        # For the case when auth 008/11 was 'z', but thesaurus was not declared in 040 $f
238
        # (which is legal in MARC 21) we try to search again with 'other' (that stands
239
        # for 008/11 = 'z') instead of biblio 6XX $7 (i.e. $self->{'thesaurus'})
240
        my $thesaurus_pos;
241
        for my $i (0..$#marclist) {
242
            if ($marclist[$i] eq 'thesaurus') {
243
                $thesaurus_pos = $i;
244
                last;
245
            }
246
        }
247
        if ($thesaurus_pos) {
248
            $value[$thesaurus_pos] = 'z';
249
            $search_query = $builder->build_authorities_query_compat(
250
                \@marclist, \@and_or, \@excluding, \@operator,
251
                \@value,    $self->{'auth_type'},
252
                'AuthidAsc'
253
            );
254
            ( $authresults, $total ) = $searcher->search_auth_compat( $search_query, 0, 20, $skipmetadata );
255
        }
256
    }
257
    return ( $authresults, $total );
262
}
258
}
263
259
264
=head1 INTERNAL FUNCTIONS
260
=head1 INTERNAL FUNCTIONS
(-)a/C4/Heading/MARC21.pm (-9 / +17 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 361-389 sub _get_subject_thesaurus { Link Here
361
361
362
    my $thesaurus = "notdefined";
362
    my $thesaurus = "notdefined";
363
    if ( $ind2 eq '0' ) {
363
    if ( $ind2 eq '0' ) {
364
        $thesaurus = "lcsh";
364
        $thesaurus = "a";
365
    }
365
    }
366
    elsif ( $ind2 eq '1' ) {
366
    elsif ( $ind2 eq '1' ) {
367
        $thesaurus = "lcac";
367
        $thesaurus = "b";
368
    }
368
    }
369
    elsif ( $ind2 eq '2' ) {
369
    elsif ( $ind2 eq '2' ) {
370
        $thesaurus = "mesh";
370
        $thesaurus = "c";
371
    }
371
    }
372
    elsif ( $ind2 eq '3' ) {
372
    elsif ( $ind2 eq '3' ) {
373
        $thesaurus = "nal";
373
        $thesaurus = "d";
374
    }
374
    }
375
    elsif ( $ind2 eq '4' ) {
375
    elsif ( $ind2 eq '4' ) {
376
        $thesaurus = "notspecified";
376
        $thesaurus = "|";
377
    }
377
    }
378
    elsif ( $ind2 eq '5' ) {
378
    elsif ( $ind2 eq '5' ) {
379
        $thesaurus = "cash";
379
        $thesaurus = "k";
380
    }
380
    }
381
    elsif ( $ind2 eq '6' ) {
381
    elsif ( $ind2 eq '6' ) {
382
        $thesaurus = "rvm";
382
        $thesaurus = "v";
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
        if (defined($sf2)) {
387
            if ($sf2 eq 'sears') {
388
                $thesaurus = 's';
389
            } elsif ($sf2 eq 'aat') {
390
                $thesaurus = 'r';
391
            } else {
392
                $thesaurus = $sf2;
393
            }
394
        }
387
    }
395
    }
388
396
389
    return $thesaurus;
397
    return $thesaurus;
(-)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/mappings.yaml (-4 lines)
Lines 813-822 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
(-)a/etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml (-3 / +6 lines)
Lines 36-44 authority-zebra-indexdefs.xsl` Link Here
36
  <kohaidx:index_control_field tag="008" offset="10" length="1">
36
  <kohaidx:index_control_field tag="008" offset="10" length="1">
37
    <kohaidx:target_index>Descriptive-cataloging-rules:w</kohaidx:target_index>
37
    <kohaidx:target_index>Descriptive-cataloging-rules:w</kohaidx:target_index>
38
  </kohaidx:index_control_field>
38
  </kohaidx:index_control_field>
39
  <kohaidx:index_subject_thesaurus tag="008" offset="11" length="1" detail_tag="040" detail_subfields="f">
39
  <kohaidx:index_control_field tag="008" offset="11" length="1">
40
    <kohaidx:target_index>Subject-heading-thesaurus:w</kohaidx:target_index>
40
    <kohaidx:target_index>Subject-heading-thesaurus:0</kohaidx:target_index>
41
  </kohaidx:index_subject_thesaurus>
41
  </kohaidx:index_control_field>
42
  <kohaidx:index_control_field tag="008" offset="14" length="1">
42
  <kohaidx:index_control_field tag="008" offset="14" length="1">
43
    <kohaidx:target_index>Heading-use-main-or-added-entry:w</kohaidx:target_index>
43
    <kohaidx:target_index>Heading-use-main-or-added-entry:w</kohaidx:target_index>
44
  </kohaidx:index_control_field>
44
  </kohaidx:index_control_field>
Lines 66-71 authority-zebra-indexdefs.xsl` Link Here
66
    <kohaidx:target_index>Record-source:w</kohaidx:target_index>
66
    <kohaidx:target_index>Record-source:w</kohaidx:target_index>
67
    <kohaidx:target_index>Record-source:p</kohaidx:target_index>
67
    <kohaidx:target_index>Record-source:p</kohaidx:target_index>
68
  </kohaidx:index_subfields>
68
  </kohaidx:index_subfields>
69
  <kohaidx:index_subfields tag="040" subfields="f">
70
    <kohaidx:target_index>Subject-heading-thesaurus:0</kohaidx:target_index>
71
  </kohaidx:index_subfields>
69
72
70
  
73
  
71
  <!-- Personal name headings -->
74
  <!-- Personal name headings -->
(-)a/etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl (-51 / +10 lines)
Lines 64-69 definition file (probably something like {biblio,authority}-koha-indexdefs.xml) Link Here
64
    <z:index name="Descriptive-cataloging-rules:w">
64
    <z:index name="Descriptive-cataloging-rules:w">
65
      <xslo:value-of select="substring(., 11, 1)"/>
65
      <xslo:value-of select="substring(., 11, 1)"/>
66
    </z:index>
66
    </z:index>
67
    <z:index name="Subject-heading-thesaurus:0">
68
      <xslo:value-of select="substring(., 12, 1)"/>
69
    </z:index>
67
    <z:index name="Heading-use-main-or-added-entry:w">
70
    <z:index name="Heading-use-main-or-added-entry:w">
68
      <xslo:value-of select="substring(., 15, 1)"/>
71
      <xslo:value-of select="substring(., 15, 1)"/>
69
    </z:index>
72
    </z:index>
Lines 100-105 definition file (probably something like {biblio,authority}-koha-indexdefs.xml) Link Here
100
        </z:index>
103
        </z:index>
101
      </xslo:if>
104
      </xslo:if>
102
    </xslo:for-each>
105
    </xslo:for-each>
106
    <xslo:for-each select="marc:subfield">
107
      <xslo:if test="contains('f', @code)">
108
        <z:index name="Subject-heading-thesaurus:0">
109
          <xslo:value-of select="."/>
110
        </z:index>
111
      </xslo:if>
112
    </xslo:for-each>
103
  </xslo:template>
113
  </xslo:template>
104
  <xslo:template mode="index_subfields" match="marc:datafield[@tag='100']">
114
  <xslo:template mode="index_subfields" match="marc:datafield[@tag='100']">
105
    <xslo:for-each select="marc:subfield">
115
    <xslo:for-each select="marc:subfield">
Lines 2410-2465 definition file (probably something like {biblio,authority}-koha-indexdefs.xml) Link Here
2410
  <xslo:variable name="general_subdivision_subfield">x</xslo:variable>
2420
  <xslo:variable name="general_subdivision_subfield">x</xslo:variable>
2411
  <xslo:variable name="chronological_subdivision_subfield">y</xslo:variable>
2421
  <xslo:variable name="chronological_subdivision_subfield">y</xslo:variable>
2412
  <xslo:variable name="geographic_subdivision_subfield">z</xslo:variable>
2422
  <xslo:variable name="geographic_subdivision_subfield">z</xslo:variable>
2413
  <xslo:template mode="index_subject_thesaurus" match="marc:controlfield[@tag='008']">
2414
    <xslo:variable name="thesaurus_code1" select="substring(., 12, 1)"/>
2415
    <xslo:variable name="full_thesaurus_code">
2416
      <xslo:choose>
2417
        <xslo:when test="$thesaurus_code1 = 'a'">
2418
          <xslo:text>lcsh</xslo:text>
2419
        </xslo:when>
2420
        <xslo:when test="$thesaurus_code1 = 'b'">
2421
          <xslo:text>lcac</xslo:text>
2422
        </xslo:when>
2423
        <xslo:when test="$thesaurus_code1 = 'c'">
2424
          <xslo:text>mesh</xslo:text>
2425
        </xslo:when>
2426
        <xslo:when test="$thesaurus_code1 = 'd'">
2427
          <xslo:text>nal</xslo:text>
2428
        </xslo:when>
2429
        <xslo:when test="$thesaurus_code1 = 'k'">
2430
          <xslo:text>cash</xslo:text>
2431
        </xslo:when>
2432
        <xslo:when test="$thesaurus_code1 = 'n'">
2433
          <xslo:text>notapplicable</xslo:text>
2434
        </xslo:when>
2435
        <xslo:when test="$thesaurus_code1 = 'r'">
2436
          <xslo:text>aat</xslo:text>
2437
        </xslo:when>
2438
        <xslo:when test="$thesaurus_code1 = 's'">
2439
          <xslo:text>sears</xslo:text>
2440
        </xslo:when>
2441
        <xslo:when test="$thesaurus_code1 = 'v'">
2442
          <xslo:text>rvm</xslo:text>
2443
        </xslo:when>
2444
        <xslo:when test="$thesaurus_code1 = 'z'">
2445
          <xslo:choose>
2446
            <xslo:when test="//marc:datafield[@tag='040']/marc:subfield[@code='f']">
2447
              <xslo:value-of select="//marc:datafield[@tag='040']/marc:subfield[@code='f']"/>
2448
            </xslo:when>
2449
            <xslo:otherwise>
2450
              <xslo:text>notdefined</xslo:text>
2451
            </xslo:otherwise>
2452
          </xslo:choose>
2453
        </xslo:when>
2454
        <xslo:otherwise>
2455
          <xslo:text>notdefined</xslo:text>
2456
        </xslo:otherwise>
2457
      </xslo:choose>
2458
    </xslo:variable>
2459
    <z:index name="Subject-heading-thesaurus:w">
2460
      <xslo:value-of select="$full_thesaurus_code"/>
2461
    </z:index>
2462
  </xslo:template>
2463
  <xslo:template mode="index_all" match="text()">
2423
  <xslo:template mode="index_all" match="text()">
2464
    <z:index name="Any:w Any:p">
2424
    <z:index name="Any:w Any:p">
2465
      <xslo:value-of select="."/>
2425
      <xslo:value-of select="."/>
2466
- 

Return to bug 32916