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

(-)a/Koha/SearchEngine/Elasticsearch.pm (-10 / +26 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 331-358 sub get_fixer_rules { Link Here
331
            # really a big deal, ES doesn't mind.
329
            # really a big deal, ES doesn't mind.
332
            $options = '-split => 1' unless $marc_field =~ m|_/| || $type eq 'sum';
330
            $options = '-split => 1' unless $marc_field =~ m|_/| || $type eq 'sum';
333
            push @rules, "marc_map('$marc_field','${name}.\$append', $options)";
331
            push @rules, "marc_map('$marc_field','${name}.\$append', $options)";
332
            if ($marc_field !~ m|_/| && ($type eq '' || $type eq 'string')) {
333
                # Handle linked fields
334
                my $tag = substr($marc_field, 0, 3);
335
                my $subfields = substr($marc_field, 3);
336
                $subfields = 'abcdefghijklmnopqrstuvwxyz' unless $subfields;
337
                my $rule = "{\$6/0-2/=\\$tag}";
338
                # Add dollars and rules to subfields
339
                $subfields =~ s/(.)/\$$1$rule/g;
340
                # Create a marc_spec rule to select correct 880 fields
341
                push @rules, "marc_spec('880${subfields}','${name}.\$append', $options)";
342
            }
334
            if ($facet) {
343
            if ($facet) {
335
                push @rules, "marc_map('$marc_field','${name}__facet.\$append', $options)";
344
                push @rules, "marc_map('$marc_field','${name}__facet.\$append', $options)";
336
            }
345
            }
337
            if ($suggestible) {
346
            if ($suggestible) {
338
                push @rules,
347
                push @rules,
339
                    #"marc_map('$marc_field','${name}__suggestion.input.\$append', $options)"; #must not have nested data structures in .input
348
                    "marc_map('$marc_field','${name}__suggestion.input.\$append', $options)";
340
                    "marc_map('$marc_field','${name}__suggestion.input.\$append')";
341
            }
349
            }
342
            if ( $type eq 'boolean' ) {
350
            if ( $type eq 'boolean' ) {
343
344
                # boolean gets special handling, basically if it doesn't exist,
351
                # boolean gets special handling, basically if it doesn't exist,
345
                # it's added and set to false. Otherwise we can't query it.
352
                # it's added and set to false. Otherwise we can't query it.
346
                push @rules,
353
                push @rules,
347
                  "unless exists('$name') add_field('$name', 0) end";
354
                  "unless exists('$name') add_field('$name', false) end";
348
            }
355
            }
349
            if ($type eq 'sum' ) {
356
            if ($type eq 'sum' ) {
350
                push @rules, "sum('$name')";
357
                push @rules, "sum('$name')";
358
            } elsif ($type eq 'isbn') {
359
                push @rules, qq{
360
do list(path:isbn, var:c)
361
    copy_field(c, isbn_tmp.\$append)
362
    isbn_versions(c)
363
    copy_field(c, isbn_tmp.\$append)
364
end
365
move_field(isbn_tmp, isbn)
366
};
351
            }
367
            }
352
            if ($self->sort_fields()->{$name}) {
368
            my $sort_fields = $self->sort_fields();
353
                if ($sort || !defined $sort) {
369
            if (defined $sort_fields->{$name} && $sort_fields->{$name}) {
354
                    push @rules, "marc_map('$marc_field','${name}__sort.\$append', $options)";
370
                push @rules, "marc_map('$marc_field','${name}__sort.\$append')";
355
                }
371
                push @rules, "join_field('${name}__sort',' ')";
356
            }
372
            }
357
        }
373
        }
358
    );
374
    );
(-)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