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

(-)a/C4/Installer/PerlDependencies.pm (-1 / +1 lines)
Lines 889-895 our $PERL_DEPS = { Link Here
889
       min_ver  => '0.17'
889
       min_ver  => '0.17'
890
    },
890
    },
891
    'Clone' => {
891
    'Clone' => {
892
        usage    => 'ILL, Test suite',
892
        usage    => 'ILL, Test suite, Elasticsearch integration',
893
        required => '1',
893
        required => '1',
894
        min_ver  => '0.37',
894
        min_ver  => '0.37',
895
    },
895
    },
(-)a/Koha/SearchEngine/Elasticsearch.pm (-10 / +12 lines)
Lines 27-32 use Koha::SearchFields; Link Here
27
use Koha::SearchMarcMaps;
27
use Koha::SearchMarcMaps;
28
28
29
use Carp;
29
use Carp;
30
use Clone qw(clone);
30
use JSON;
31
use JSON;
31
use Modern::Perl;
32
use Modern::Perl;
32
use Readonly;
33
use Readonly;
Lines 193-205 sub get_elasticsearch_mappings { Link Here
193
194
194
    if (!defined $all_mappings{$self->index}) {
195
    if (!defined $all_mappings{$self->index}) {
195
        $sort_fields{$self->index} = {};
196
        $sort_fields{$self->index} = {};
197
        # Clone the general mapping to break ties with the original hash
196
        my $mappings = {
198
        my $mappings = {
197
            data => scalar _get_elasticsearch_mapping('general', '')
199
            data => clone(_get_elasticsearch_field_config('general', ''))
198
        };
200
        };
199
        my $marcflavour = lc C4::Context->preference('marcflavour');
201
        my $marcflavour = lc C4::Context->preference('marcflavour');
200
        $self->_foreach_mapping(
202
        $self->_foreach_mapping(
201
            sub {
203
            sub {
202
                my ( $name, $type, $facet, $suggestible, $sort, $marc_type ) = @_;
204
                my ( $name, $type, $facet, $suggestible, $sort, $marc_type ) = @_;
205
203
                return if $marc_type ne $marcflavour;
206
                return if $marc_type ne $marcflavour;
204
                # TODO if this gets any sort of complexity to it, it should
207
                # TODO if this gets any sort of complexity to it, it should
205
                # be broken out into its own function.
208
                # be broken out into its own function.
Lines 215-233 sub get_elasticsearch_mappings { Link Here
215
                    $es_type = 'stdno';
218
                    $es_type = 'stdno';
216
                }
219
                }
217
220
218
                $mappings->{data}{properties}{$name} = _get_elasticsearch_mapping('search', $es_type);
221
                $mappings->{data}{properties}{$name} = _get_elasticsearch_field_config('search', $es_type);
219
222
220
                if ($facet) {
223
                if ($facet) {
221
                    $mappings->{data}{properties}{ $name . '__facet' } = _get_elasticsearch_mapping('facet', $es_type);
224
                    $mappings->{data}{properties}{ $name . '__facet' } = _get_elasticsearch_field_config('facet', $es_type);
222
                }
225
                }
223
                if ($suggestible) {
226
                if ($suggestible) {
224
                    $mappings->{data}{properties}{ $name . '__suggestion' } = _get_elasticsearch_mapping('suggestible', $es_type);
227
                    $mappings->{data}{properties}{ $name . '__suggestion' } = _get_elasticsearch_field_config('suggestible', $es_type);
225
                }
228
                }
226
                # Sort is a bit special as it can be true, false, undef.
229
                # Sort is a bit special as it can be true, false, undef.
227
                # We care about "true" or "undef",
230
                # We care about "true" or "undef",
228
                # "undef" means to do the default thing, which is make it sortable.
231
                # "undef" means to do the default thing, which is make it sortable.
229
                if (!defined $sort || $sort) {
232
                if (!defined $sort || $sort) {
230
                    $mappings->{data}{properties}{ $name . '__sort' } = _get_elasticsearch_mapping('sort', $es_type);
233
                    $mappings->{data}{properties}{ $name . '__sort' } = _get_elasticsearch_field_config('sort', $es_type);
231
                    $sort_fields{$self->index}{$name} = 1;
234
                    $sort_fields{$self->index}{$name} = 1;
232
                }
235
                }
233
            }
236
            }
Lines 239-253 sub get_elasticsearch_mappings { Link Here
239
    return $all_mappings{$self->index};
242
    return $all_mappings{$self->index};
240
}
243
}
241
244
242
=head2 _get_elasticsearch_mapping
245
=head2 _get_elasticsearch_field_config
243
246
244
Get the Elasticsearch mappings for the given purpose and data type.
247
Get the Elasticsearch field config for the given purpose and data type.
245
248
246
$mapping = _get_elasticsearch_mapping('search', 'text');
249
$mapping = _get_elasticsearch_field_config('search', 'text');
247
250
248
=cut
251
=cut
249
252
250
sub _get_elasticsearch_mapping {
253
sub _get_elasticsearch_field_config {
251
254
252
    my ( $purpose, $type ) = @_;
255
    my ( $purpose, $type ) = @_;
253
256
254
- 

Return to bug 22474