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

(-)a/C4/Heading.pm (-24 / +1 lines)
Lines 210-243 sub _search { Link Here
210
    }
210
    }
211
211
212
    if ( $thesaurus ) {
212
    if ( $thesaurus ) {
213
    # This is calculated in C4/Heading/MARC21.pm - not used for UNIMARC
214
        if ($thesaurus eq 'lcsh') {
215
            $subject_heading_thesaurus = 'a';
216
        } elsif ($thesaurus eq 'lcac') {
217
            $subject_heading_thesaurus = 'b';
218
        } elsif ($thesaurus eq 'mesh') {
219
            $subject_heading_thesaurus = 'c';
220
        } elsif ($thesaurus eq 'nal') {
221
            $subject_heading_thesaurus = 'd';
222
        } elsif ($thesaurus eq 'notspecified') {
223
            $subject_heading_thesaurus = 'n';
224
        } elsif ($thesaurus eq 'cash') {
225
            $subject_heading_thesaurus = 'k';
226
        } elsif ($thesaurus eq 'rvm') {
227
            $subject_heading_thesaurus = 'v';
228
        } else { # We stored the value from $7 as the thesaurus if there was one
229
            $subject_heading_thesaurus = 'z';
230
            push @marclist, 'thesaurus-conventions';
231
            push @and_or, 'and';
232
            push @excluding, '';
233
            push @operator, 'is';
234
            push @value, $self->{'thesaurus'};
235
        }
236
        push @marclist, 'thesaurus';
213
        push @marclist, 'thesaurus';
237
        push @and_or, 'and';
214
        push @and_or, 'and';
238
        push @excluding, '';
215
        push @excluding, '';
239
        push @operator, 'is';
216
        push @operator, 'is';
240
        push @value, $subject_heading_thesaurus;
217
        push @value, $thesaurus;
241
    }
218
    }
242
219
243
    require Koha::SearchEngine::QueryBuilder;
220
    require Koha::SearchEngine::QueryBuilder;
(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +9 lines)
Lines 233-239 sub get_elasticsearch_mappings { Link Here
233
                }
233
                }
234
            }
234
            }
235
        );
235
        );
236
        $mappings->{properties}{ 'match-heading' } = _get_elasticsearch_field_config('search', 'text') if $self->index eq 'authorities';
236
        if( $self->index eq 'authorities' ){
237
            $mappings->{properties}{ 'match-heading' } = _get_elasticsearch_field_config('search', 'text');
238
            $mappings->{properties}{ 'subject-heading-thesaurus' } = _get_elasticsearch_field_config('search', 'text');
239
        }
237
        $all_mappings{$self->index} = $mappings;
240
        $all_mappings{$self->index} = $mappings;
238
    }
241
    }
239
    $self->sort_fields(\%{$sort_fields{$self->index}});
242
    $self->sort_fields(\%{$sort_fields{$self->index}});
Lines 1166-1171 sub _get_marc_mapping_rules { Link Here
1166
        }
1169
        }
1167
    }
1170
    }
1168
1171
1172
    if( $self->index eq 'authorities' ){
1173
        push @{$rules->{control_fields}->{'008'}}, ['subject-heading-thesaurus', { 'substr' => [ 11, 1 ] } ];
1174
        push @{$rules->{data_fields}->{'040'}->{subfields}->{f}}, ['subject-heading-thesaurus', { } ];
1175
    }
1176
1169
    return $rules;
1177
    return $rules;
1170
}
1178
}
1171
1179
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (+12 lines)
Lines 564-569 our $koha_to_index_name = { Link Here
564
    all             => ''
564
    all             => ''
565
};
565
};
566
566
567
our $thesaurus_to_value = {
568
   lcsh => 'a',
569
   lcac => 'b',
570
   mesh => 'c',
571
   nal  => 'd',
572
   notspecified => 'n',
573
   cash => 'k',
574
   rvm => 'v',
575
};
576
567
sub build_authorities_query_compat {
577
sub build_authorities_query_compat {
568
    my ( $self, $marclist, $and_or, $excluding, $operator, $value,
578
    my ( $self, $marclist, $and_or, $excluding, $operator, $value,
569
        $authtypecode, $orderby )
579
        $authtypecode, $orderby )
Lines 588-593 sub build_authorities_query_compat { Link Here
588
    }
598
    }
589
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
599
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
590
        next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches
600
        next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches
601
        $value->[$i] = $thesaurus_to_value->{ $value->[$i] }
602
            if( defined $thesaurus_to_value->{ $value->[$i] } && $indexes[$i] eq 'subject-heading-thesaurus' );
591
        push @searches,
603
        push @searches,
592
          {
604
          {
593
            where    => $indexes[$i],
605
            where    => $indexes[$i],
(-)a/admin/searchengine/elasticsearch/mappings.yaml (-18 lines)
Lines 805-828 authorities: Link Here
805
        sort: ~
805
        sort: ~
806
        suggestible: ''
806
        suggestible: ''
807
    type: ''
807
    type: ''
808
  Subject-heading-thesaurus:
809
    label: Subject-heading-thesaurus
810
    mappings:
811
      - facet: ''
812
        marc_field: 008_/11
813
        marc_type: marc21
814
        sort: ~
815
        suggestible: ''
816
    type: ''
817
  Subject-heading-thesaurus-conventions:
818
    label: Subject-heading-thesaurus-conventions
819
    mappings:
820
      - facet: ''
821
        marc_field: 040f
822
        marc_type: marc21
823
        sort: ~
824
        suggestible: ''
825
    type: ''
826
  authtype:
808
  authtype:
827
    label: authtype
809
    label: authtype
828
    mappings:
810
    mappings:
(-)a/t/db_dependent/Heading.t (-3 / +1 lines)
Lines 102-109 subtest "_search tests" => sub { Link Here
102
    $terms = $search_query->{query}->{bool}->{must};
102
    $terms = $search_query->{query}->{bool}->{must};
103
    $expected_terms = [
103
    $expected_terms = [
104
        { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } },
104
        { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } },
105
        { term => { 'subject-heading-thesaurus-conventions.ci_raw' => 'special_sauce' } },
105
        { term => { 'subject-heading-thesaurus.ci_raw' => 'special_sauce' } },
106
        { term => { 'subject-heading-thesaurus.ci_raw' => 'z' } },
107
    ];
106
    ];
108
    is_deeply( $terms, $expected_terms, "Search formed as expected with second indicator 7 and subfield 2");
107
    is_deeply( $terms, $expected_terms, "Search formed as expected with second indicator 7 and subfield 2");
109
108
110
- 

Return to bug 33159