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 192-204 sub get_elasticsearch_mappings { Link Here
192
193
193
    if (!defined $all_mappings{$self->index}) {
194
    if (!defined $all_mappings{$self->index}) {
194
        $sort_fields{$self->index} = {};
195
        $sort_fields{$self->index} = {};
196
        # Clone the general mapping to break ties with the original hash
195
        my $mappings = {
197
        my $mappings = {
196
            data => scalar _get_elasticsearch_mapping('general', '')
198
            data => clone(_get_elasticsearch_field_config('general', ''))
197
        };
199
        };
198
        my $marcflavour = lc C4::Context->preference('marcflavour');
200
        my $marcflavour = lc C4::Context->preference('marcflavour');
199
        $self->_foreach_mapping(
201
        $self->_foreach_mapping(
200
            sub {
202
            sub {
201
                my ( $name, $type, $facet, $suggestible, $sort, $marc_type ) = @_;
203
                my ( $name, $type, $facet, $suggestible, $sort, $marc_type ) = @_;
204
202
                return if $marc_type ne $marcflavour;
205
                return if $marc_type ne $marcflavour;
203
                # TODO if this gets any sort of complexity to it, it should
206
                # TODO if this gets any sort of complexity to it, it should
204
                # be broken out into its own function.
207
                # be broken out into its own function.
Lines 214-232 sub get_elasticsearch_mappings { Link Here
214
                    $es_type = 'stdno';
217
                    $es_type = 'stdno';
215
                }
218
                }
216
219
217
                $mappings->{data}{properties}{$name} = _get_elasticsearch_mapping('search', $es_type);
220
                $mappings->{data}{properties}{$name} = _get_elasticsearch_field_config('search', $es_type);
218
221
219
                if ($facet) {
222
                if ($facet) {
220
                    $mappings->{data}{properties}{ $name . '__facet' } = _get_elasticsearch_mapping('facet', $es_type);
223
                    $mappings->{data}{properties}{ $name . '__facet' } = _get_elasticsearch_field_config('facet', $es_type);
221
                }
224
                }
222
                if ($suggestible) {
225
                if ($suggestible) {
223
                    $mappings->{data}{properties}{ $name . '__suggestion' } = _get_elasticsearch_mapping('suggestible', $es_type);
226
                    $mappings->{data}{properties}{ $name . '__suggestion' } = _get_elasticsearch_field_config('suggestible', $es_type);
224
                }
227
                }
225
                # Sort is a bit special as it can be true, false, undef.
228
                # Sort is a bit special as it can be true, false, undef.
226
                # We care about "true" or "undef",
229
                # We care about "true" or "undef",
227
                # "undef" means to do the default thing, which is make it sortable.
230
                # "undef" means to do the default thing, which is make it sortable.
228
                if (!defined $sort || $sort) {
231
                if (!defined $sort || $sort) {
229
                    $mappings->{data}{properties}{ $name . '__sort' } = _get_elasticsearch_mapping('sort', $es_type);
232
                    $mappings->{data}{properties}{ $name . '__sort' } = _get_elasticsearch_field_config('sort', $es_type);
230
                    $sort_fields{$self->index}{$name} = 1;
233
                    $sort_fields{$self->index}{$name} = 1;
231
                }
234
                }
232
            }
235
            }
Lines 238-252 sub get_elasticsearch_mappings { Link Here
238
    return $all_mappings{$self->index};
241
    return $all_mappings{$self->index};
239
}
242
}
240
243
241
=head2 _get_elasticsearch_mapping
244
=head2 _get_elasticsearch_field_config
242
245
243
Get the Elasticsearch mappings for the given purpose and data type.
246
Get the Elasticsearch field config for the given purpose and data type.
244
247
245
$mapping = _get_elasticsearch_mapping('search', 'text');
248
$mapping = _get_elasticsearch_field_config('search', 'text');
246
249
247
=cut
250
=cut
248
251
249
sub _get_elasticsearch_mapping {
252
sub _get_elasticsearch_field_config {
250
253
251
    my ( $purpose, $type ) = @_;
254
    my ( $purpose, $type ) = @_;
252
255
253
- 

Return to bug 22474