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

(-)a/Koha/SearchEngine/Elasticsearch.pm (-15 / +27 lines)
Lines 34-41 use Search::Elasticsearch; Link Here
34
use Try::Tiny;
34
use Try::Tiny;
35
use YAML::Syck;
35
use YAML::Syck;
36
36
37
use Data::Dumper;    # TODO remove
38
39
__PACKAGE__->mk_ro_accessors(qw( index ));
37
__PACKAGE__->mk_ro_accessors(qw( index ));
40
__PACKAGE__->mk_accessors(qw( sort_fields ));
38
__PACKAGE__->mk_accessors(qw( sort_fields ));
41
39
Lines 325-358 sub get_fixer_rules { Link Here
325
            return if $marc_type ne $marcflavour;
323
            return if $marc_type ne $marcflavour;
326
            my $options = '';
324
            my $options = '';
327
325
328
            # There's a bug when using 'split' with something that
326
            $options = "join:' '" unless $marc_field =~ m|_/| || $type eq 'sum';
329
            # selects a range
330
            # The split makes everything into nested arrays, but that's not
331
            # really a big deal, ES doesn't mind.
332
            $options = '-split => 1' unless $marc_field =~ m|_/| || $type eq 'sum';
333
            push @rules, "marc_map('$marc_field','${name}.\$append', $options)";
327
            push @rules, "marc_map('$marc_field','${name}.\$append', $options)";
328
            if ($marc_field !~ m|_/| && ($type eq '' || $type eq 'string')) {
329
                # Handle linked fields
330
                my $tag = substr($marc_field, 0, 3);
331
                my $subfields = substr($marc_field, 3);
332
                $subfields = 'abcdefghijklmnopqrstuvwxyz' unless $subfields;
333
                my $rule = "{\$6/0-2/=\\$tag}";
334
                # Add dollars and rules to subfields
335
                $subfields =~ s/(.)/\$$1$rule/g;
336
                # Create a marc_spec rule to select correct 880 fields
337
                push @rules, "marc_spec('880${subfields}','${name}.\$append', $options)";
338
            }
334
            if ($facet) {
339
            if ($facet) {
335
                push @rules, "marc_map('$marc_field','${name}__facet.\$append', $options)";
340
                push @rules, "marc_map('$marc_field','${name}__facet.\$append', $options)";
336
            }
341
            }
337
            if ($suggestible) {
342
            if ($suggestible) {
338
                push @rules,
343
                push @rules,
339
                    #"marc_map('$marc_field','${name}__suggestion.input.\$append', $options)"; #must not have nested data structures in .input
344
                    "marc_map('$marc_field','${name}__suggestion.input.\$append', $options)";
340
                    "marc_map('$marc_field','${name}__suggestion.input.\$append')";
341
            }
345
            }
342
            if ( $type eq 'boolean' ) {
346
            if ( $type eq 'boolean' ) {
343
344
                # boolean gets special handling, basically if it doesn't exist,
347
                # boolean gets special handling, basically if it doesn't exist,
345
                # it's added and set to false. Otherwise we can't query it.
348
                # it's added and set to false. Otherwise we can't query it.
346
                push @rules,
349
                push @rules,
347
                  "unless exists('$name') add_field('$name', 0) end";
350
                  "unless exists('$name') add_field('$name', false) end";
348
            }
351
            }
349
            if ($type eq 'sum' ) {
352
            if ($type eq 'sum' ) {
350
                push @rules, "sum('$name')";
353
                push @rules, "sum('$name')";
354
            } elsif ($type eq 'isbn') {
355
                push @rules, qq{
356
do list(path:isbn, var:c)
357
    copy_field(c, isbn_tmp.\$append)
358
    isbn_versions(c)
359
    copy_field(c, isbn_tmp.\$append)
360
end
361
move_field(isbn_tmp, isbn)
362
};
351
            }
363
            }
352
            if ($self->sort_fields()->{$name}) {
364
            my $sort_fields = $self->sort_fields();
353
                if ($sort || !defined $sort) {
365
            if (defined $sort_fields->{$name} && $sort_fields->{$name}) {
354
                    push @rules, "marc_map('$marc_field','${name}__sort.\$append', $options)";
366
                push @rules, "marc_map('$marc_field','${name}__sort.\$append')";
355
                }
367
                push @rules, "join_field('${name}__sort',' ')";
356
            }
368
            }
357
        }
369
        }
358
    );
370
    );
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-4 / +3 lines)
Lines 200-208 sub search_auth_compat { Link Here
200
200
201
            # I wonder if these should be real values defined in the mapping
201
            # I wonder if these should be real values defined in the mapping
202
            # rather than hard-coded conversions.
202
            # rather than hard-coded conversions.
203
            # Our results often come through as nested arrays, to fix this
203
            # Handle legacy nested arrays indexed with splitting enabled.
204
            # requires changes in catmandu.
204
            my $authid = $record->{ 'Local-number' }[0];
205
            my $authid = $record->{ 'Local-number' }[0][0];
205
            $authid = @$authid[0] if (ref $authid eq 'ARRAY');
206
            $result{authid} = $authid;
206
            $result{authid} = $authid;
207
207
208
            # TODO put all this info into the record at index time so we
208
            # TODO put all this info into the record at index time so we
209
- 

Return to bug 20244