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

(-)a/Koha/QueryParser/Driver/PQF.pm (+913 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF;
2
use base qw(OpenILS::QueryParser Class::Accessor);
3
4
use strict;
5
use warnings;
6
7
use Module::Load::Conditional qw(can_load);
8
use Koha::QueryParser::Driver::PQF::Util;
9
use Koha::QueryParser::Driver::PQF::query_plan;
10
use Koha::QueryParser::Driver::PQF::query_plan::facet;
11
use Koha::QueryParser::Driver::PQF::query_plan::filter;
12
use Koha::QueryParser::Driver::PQF::query_plan::modifier;
13
use Koha::QueryParser::Driver::PQF::query_plan::node;
14
use Koha::QueryParser::Driver::PQF::query_plan::node::atom;
15
use Koha::QueryParser::Driver::PQF::query_plan::node::atom;
16
17
18
=head1 NAME
19
20
Koha::QueryParser::Driver::PQF - QueryParser driver for PQF
21
22
=head1 SYNOPSIS
23
24
    use Koha::QueryParser::Driver::PQF;
25
    my $QParser = Koha::QueryParser::Driver::PQF->new(%args);
26
27
=head1 DESCRIPTION
28
29
Main entrypoint into the QueryParser PQF driver. PQF is the Prefix Query
30
Language, the syntax used to serialize Z39.50 queries.
31
32
=head1 ACCESSORS
33
34
In order to simplify Bib-1 attribute mapping, this driver uses Class::Accessor
35
for accessing the following maps:
36
37
=over 4
38
39
=item B<bib1_field_map> - search class/field Bib-1 mappings
40
41
=item B<bib1_modifier_map> - search modifier mappings
42
43
=item B<bib1_filter_map> - search filter mappings
44
45
=item B<bib1_relevance_bump_map> - relevance bump mappings
46
47
=back
48
49
=cut
50
51
__PACKAGE__->mk_accessors(qw(bib1_field_map bib1_modifier_map bib1_filter_map bib1_relevance_bump_map));
52
53
=head1 FUNCTIONS
54
55
=cut
56
57
=head2 get
58
59
Overridden accessor method for Class::Accessor. (Do not call directly)
60
61
=cut
62
63
sub get {
64
    my $self = shift;
65
    return $self->_map(@_);
66
}
67
68
=head2 set
69
70
Overridden mutator method for Class::Accessor. (Do not call directly)
71
72
=cut
73
74
sub set {
75
    my $self = shift;
76
    return $self->_map(@_);
77
}
78
79
=head2 add_bib1_field_map
80
81
    $QParser->add_bib1_field_map($class => $field => $server => \%attributes);
82
83
    $QParser->add_bib1_field_map('author' => 'personal' => 'biblioserver' =>
84
                                    { '1' => '1003' });
85
86
Adds a search field<->bib1 attribute mapping for the specified server. The
87
%attributes hash contains maps Bib-1 Attributes to the appropropriate
88
values. Not all attributes must be specified.
89
90
=cut
91
92
sub add_bib1_field_map {
93
    my ($self, $class, $field, $server, $attributes) = @_;
94
95
    $self->add_search_field( $class => $field );
96
    $self->add_search_field_alias( $class => $field => $field );
97
    return $self->_add_field_mapping($self->bib1_field_map, $class, $field, $server, $attributes);
98
}
99
100
=head2 add_bib1_modifier_map
101
102
    $QParser->add_bib1_modifier_map($name => $server => \%attributes);
103
104
    $QParser->add_bib1_modifier_map('ascending' => 'biblioserver' =>
105
                                    { '7' => '1' });
106
107
Adds a search modifier<->bib1 attribute mapping for the specified server. The
108
%attributes hash contains maps Bib-1 Attributes to the appropropriate
109
values. Not all attributes must be specified.
110
111
=cut
112
113
sub add_bib1_modifier_map {
114
    my ($self, $name, $server, $attributes) = @_;
115
116
    $self->add_search_modifier( $name );
117
118
    return $self->_add_mapping($self->bib1_modifier_map, $name, $server, $attributes);
119
}
120
121
=head2 add_bib1_filter_map
122
123
    $QParser->add_bib1_filter_map($name => $server => \%attributes);
124
125
    $QParser->add_bib1_filter_map('date' => 'biblioserver' =>
126
                                    { 'callback' => &_my_callback });
127
128
Adds a search filter<->bib1 attribute mapping for the specified server. The
129
%attributes hash maps Bib-1 Attributes to the appropropriate values and
130
provides a callback for the filter. Not all attributes must be specified.
131
132
=cut
133
134
sub add_bib1_filter_map {
135
    my ($self, $name, $server, $attributes) = @_;
136
137
    $self->add_search_filter( $name, $attributes->{'callback'} );
138
139
    return $self->_add_mapping($self->bib1_filter_map, $name, $server, $attributes);
140
}
141
142
=head2 add_relevance_bump
143
144
    $QParser->add_relevance_bump($class, $field, $server, $multiplier, $active);
145
    $QParser->add_relevance_bump('title' => 'exact' => 'biblioserver' => 34, 1);
146
147
Add a relevance bump to the specified field. When searching for a class without
148
any fields, all the relevance bumps for the specified class will be 'OR'ed
149
together.
150
151
=cut
152
153
sub add_relevance_bump {
154
    my ($self, $class, $field, $server, $multiplier, $active) = @_;
155
    my $attributes = { '9' => $multiplier, '2' => '102', 'active' => $active };
156
157
    $self->add_search_field( $class => $field );
158
    return $self->_add_field_mapping($self->bib1_relevance_bump_map, $class, $field, $server, $attributes);
159
}
160
161
162
=head2 target_syntax
163
164
    my $pqf = $QParser->target_syntax($server, [$query]);
165
    my $pqf = $QParser->target_syntax('biblioserver', 'author|personal:smith');
166
    print $pqf; # assuming all the indexes are configured,
167
                # prints '@attr 1=1003 @attr 4=6 "smith"'
168
169
Transforms the current or specified query into a PQF query string for the
170
specified server.
171
172
=cut
173
174
sub target_syntax {
175
    my ($self, $server, $query) = @_;
176
    my $pqf = '';
177
    $self->parse($query) if $query;
178
    warn "QP query for $server: " . $self->query . "\n" if $self->debug;
179
    $pqf = $self->parse_tree->target_syntax($server);
180
    warn "PQF query: $pqf\n" if $self->debug;
181
    $pqf =~ s/ +/ /g;
182
    $pqf =~ s/^ //;
183
    $pqf =~ s/ $//;
184
    return $pqf;
185
}
186
187
=head2 date_filter_target_callback
188
189
    $QParser->add_bib1_filter_map($server, { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => 'pubdate' });
190
191
Callback for date filters. Note that although the first argument is the QParser
192
object, this is technically not an object-oriented routine. This has no
193
real-world implications.
194
195
=cut
196
197
sub date_filter_target_callback {
198
    my ($QParser, $filter, $params, $negate, $server) = @_;
199
    my $attr_string = $QParser->bib1_mapping_by_name( 'filter', $filter, $server )->{'attr_string'};
200
    my $pqf = '';
201
    foreach my $datespec (@$params) {
202
        my $datepqf = ' ';
203
        if ($datespec) {
204
            if ($datespec =~ m/(.*)-(.*)/) {
205
                if ($1) {
206
                    $datepqf .= $attr_string . ' @attr 2=4 "' . $1 . '"';
207
                }
208
                if ($2) {
209
                    $datepqf .= $attr_string . ' @attr 2=2 "' . $2 . '"';
210
                    $datepqf = ' @and ' . $datepqf if $1;
211
                }
212
            } else {
213
                $datepqf .= $attr_string . ' "' . $datespec . '"';
214
            }
215
        }
216
        $pqf = ' @or ' . ($negate ? '@not @attr 1=_ALLRECORDS @attr 2=103 "" ' : '') . $pqf if $pqf;
217
        $pqf .= $datepqf;
218
    }
219
    return $pqf;
220
}
221
222
=head2 _map
223
224
    return $self->_map('bib1_field_map', $map);
225
226
Retrieves or sets a map.
227
228
=cut
229
230
sub _map {
231
    my ($self, $name, $map) = @_;
232
    $self->custom_data->{$name} ||= {};
233
    $self->custom_data->{$name} = $map if ($map);
234
    return $self->custom_data->{$name};
235
}
236
237
=head2 _add_mapping
238
239
    return $self->_add_mapping($map, $name, $server, $attributes)
240
241
Adds a mapping. Note that this is not used for mappings relating to fields.
242
243
=cut
244
245
sub _add_mapping {
246
    my ($self, $map, $name, $server, $attributes) = @_;
247
248
    my $attr_string = Koha::QueryParser::Driver::PQF::Util::attributes_to_attr_string($attributes);
249
    $attributes->{'attr_string'} = $attr_string;
250
251
    $map->{'by_name'}{$name}{$server} = $attributes;
252
    $map->{'by_attr'}{$server}{$attr_string} = { 'name' => $name, %$attributes };
253
254
    return $map;
255
}
256
257
=head2 _add_field_mapping
258
259
    return $self->_add_field_mapping($map, $class, $field, $server, $attributes)
260
261
Adds a mapping for field-related data.
262
263
=cut
264
265
sub _add_field_mapping {
266
    my ($self, $map, $class, $field, $server, $attributes) = @_;
267
    my $attr_string = Koha::QueryParser::Driver::PQF::Util::attributes_to_attr_string($attributes);
268
    $attributes->{'attr_string'} = $attr_string;
269
270
    $map->{'by_name'}{$class}{$field}{$server} = $attributes;
271
    $map->{'by_attr'}{$server}{$attr_string} = { 'classname' => $class, 'field' => $field, %$attributes };
272
    return $map;
273
}
274
275
276
=head2 bib1_mapping_by_name
277
278
    my $attributes = $QParser->bib1_mapping_by_name($type, $name[, $subname], $server);
279
    my $attributes = $QParser->bib1_mapping_by_name('field', 'author', 'personal', 'biblioserver');
280
    my $attributes = $QParser->bib1_mapping_by_name('filter', 'pubdate', 'biblioserver');
281
282
Retrieve the Bib-1 attribute set associated with the specified mapping.
283
=cut
284
285
sub bib1_mapping_by_name {
286
    my $server = pop;
287
    my ($self, $type, $name, $field) = @_;
288
289
    return unless ($server && $name);
290
    return unless ($type eq 'field' || $type eq 'modifier' || $type eq 'filter' || $type eq 'relevance_bump');
291
    if ($type eq 'field' || $type eq 'relevance_bump') {
292
    # Unfortunately field is a special case thanks to the class->field hierarchy
293
        return $self->_map('bib1_' . $type . '_map')->{'by_name'}{$name}{$field}{$server} if $field;
294
        return $self->_map('bib1_' . $type . '_map')->{'by_name'}{$name};
295
    } else {
296
        return $self->_map('bib1_' . $type . '_map')->{'by_name'}{$name}{$server};
297
    }
298
}
299
300
=head2 bib1_mapping_by_attr
301
302
    my $field = $QParser->bib1_mapping_by_attr($type, $server, \%attr);
303
    my $field = $QParser->bib1_mapping_by_attr('field', 'biblioserver', {'1' => '1004'});
304
    print $field->{'classname'}; # prints "author"
305
    print $field->{'field'}; # prints "personal"
306
307
Retrieve the search field/modifier/filter used for the specified Bib-1 attribute set.
308
309
=cut
310
311
sub bib1_mapping_by_attr {
312
    my ($self, $type, $server, $attributes) = @_;
313
    return unless ($server && $attributes);
314
315
    my $attr_string = Koha::QueryParser::Driver::PQF::Util::attributes_to_attr_string($attributes);
316
317
    return $self->bib1_mapping_by_attr_string($type, $server, $attr_string);
318
}
319
320
=head2 bib1_mapping_by_attr_string
321
322
    my $field = $QParser->bib1_mapping_by_attr_string($type, $server, $attr_string);
323
    my $field = $QParser->bib1_mapping_by_attr_string('field', 'biblioserver', '@attr 1=1004');
324
    print $field->{'classname'}; # prints "author"
325
    print $field->{'field'}; # prints "personal"
326
327
Retrieve the search field/modifier/filter used for the specified Bib-1 attribute string
328
(i.e. PQF snippet).
329
330
=cut
331
332
sub bib1_mapping_by_attr_string {
333
    my ($self, $type, $server, $attr_string) = @_;
334
    return unless ($server && $attr_string);
335
    return unless ($type eq 'field' || $type eq 'modifier' || $type eq 'filter' || $type eq 'relevance_bump');
336
337
    return $self->_map('bib1_' . $type . '_map')->{'by_attr'}{$server}{$attr_string};
338
}
339
340
=head2 clear_all_configuration
341
    
342
    $QParser->clear_all_configuration
343
344
Clear all configuration. This is a highly destructive method. You may
345
not want to use it.
346
347
=cut
348
349
sub clear_all_configuration {
350
    my ($self) = @_;
351
    %OpenILS::QueryParser::parser_config = (
352
            'OpenILS::QueryParser' => {
353
            filters => [],
354
            modifiers => [],
355
            operators => {
356
            'and' => '&&',
357
            'or' => '||',
358
            float_start => '{{',
359
            float_end => '}}',
360
            group_start => '(',
361
            group_end => ')',
362
            required => '+',
363
            disallowed => '-',
364
            modifier => '#',
365
            negated => '!'
366
            }
367
            }
368
            );
369
    return $self;
370
}
371
372
=head2 clear_all_mappings
373
    
374
    $QParser->clear_all_mappings
375
376
Clear all bib-1 mappings.
377
378
=cut
379
380
sub clear_all_mappings {
381
    my ($self) = @_;
382
383
    foreach my $name (qw(field modifier filter relevance_bump)) {
384
        $self->custom_data->{'bib1_' . $name . '_map'} = { };
385
    }
386
    return $self;
387
}
388
389
390
=head2 _canonicalize_field_map
391
392
Convert a field map into its canonical form for serialization. Used only for
393
fields and relevance bumps.
394
395
=cut
396
397
sub _canonicalize_field_map {
398
    my ( $map, $aliases ) = @_;
399
    my $canonical_map = {};
400
401
    foreach my $class ( keys %{ $map->{'by_name'} } ) {
402
        $canonical_map->{$class} ||= {};
403
        foreach my $field ( keys %{ $map->{'by_name'}->{$class} } ) {
404
            my $field_map = {
405
                'index'   => $field,
406
                'label'   => ucfirst($field),
407
                'enabled' => '1',
408
            };
409
            foreach
410
              my $server ( keys %{ $map->{'by_name'}->{$class}->{$field} } )
411
            {
412
                $field_map->{'bib1_mapping'} ||= {};
413
                $field_map->{'bib1_mapping'}->{$server} =
414
                  $map->{'by_name'}->{$class}->{$field}->{$server};
415
                delete $field_map->{'bib1_mapping'}->{$server}->{'attr_string'}
416
                  if defined(
417
                          $field_map->{'bib1_mapping'}->{$server}
418
                            ->{'attr_string'}
419
                  );
420
            }
421
            if ($aliases) {
422
                $field_map->{'aliases'} = [];
423
                foreach my $alias ( @{ $aliases->{$class}->{$field} } ) {
424
                    push @{ $field_map->{'aliases'} },
425
                      $alias;
426
                }
427
            }
428
            $canonical_map->{$class}->{$field} = $field_map;
429
        }
430
    }
431
    return $canonical_map;
432
}
433
434
=head2 _canonicalize_map
435
436
Convert a map into its canonical form for serialization. Not used for fields.
437
438
=cut
439
440
sub _canonicalize_map {
441
    my ($map) = @_;
442
    my $canonical_map = {};
443
444
    foreach my $name ( keys %{ $map->{'by_name'} } ) {
445
        $canonical_map->{$name} = {
446
            'label'        => ucfirst($name),
447
            'enabled'      => 1,
448
            'bib1_mapping' => {}
449
        };
450
        foreach my $server ( keys %{ $map->{'by_name'}->{$name} } ) {
451
            $canonical_map->{$name}->{'bib1_mapping'}->{$server} =
452
              $map->{'by_name'}->{$name}->{$server};
453
            delete $canonical_map->{$name}->{'bib1_mapping'}->{$server}
454
              ->{'attr_string'}
455
              if defined(
456
                      $canonical_map->{$name}->{'bib1_mapping'}->{$server}
457
                        ->{'attr_string'}
458
              );
459
        }
460
    }
461
    return $canonical_map;
462
}
463
464
=head2 serialize_mappings
465
466
    my $yaml = $QParser->serialize_mappings;
467
    my $json = $QParser->serialize_mappings('json');
468
469
Serialize Bib-1 mappings to YAML or JSON.
470
471
=cut
472
473
sub serialize_mappings {
474
    my ( $self, $format ) = @_;
475
    $format ||= 'yaml';
476
    my $config;
477
478
    $config->{'field_mappings'} =
479
      _canonicalize_field_map( $self->bib1_field_map,
480
        $self->search_field_aliases );
481
    $config->{'modifier_mappings'} =
482
      _canonicalize_map( $self->bib1_modifier_map );
483
    $config->{'filter_mappings'} = _canonicalize_map( $self->bib1_filter_map );
484
    $config->{'relevance_bumps'} =
485
      _canonicalize_field_map( $self->bib1_relevance_bump_map );
486
487
    if ( $format eq 'json' && can_load( modules => { 'JSON' => undef } ) ) {
488
        return JSON::to_json($config);
489
    }
490
    elsif ( can_load( modules => { 'YAML::Any' => undef } ) ) {
491
        return YAML::Any::Dump($config);
492
    }
493
    return;
494
}
495
496
=head2 initialize
497
498
    $QParser->initialize( { 'bib1_field_mappings' => \%bib1_field_mappings,
499
                            'search_field_alias_mappings' => \%search_field_alias_mappings,
500
                            'bib1_modifier_mappings' => \%bib1_modifier_mappings,
501
                            'bib1_filter_mappings' => \%bib1_filter_mappings,
502
                            'relevance_bumps' => \%relevance_bumps });
503
504
Initialize the QueryParser mapping tables based on the provided configuration.
505
This method was written to play nice with YAML configuration files loaded by load_config.
506
507
=cut
508
509
sub initialize {
510
    my ( $self, $args ) = @_;
511
512
    my $field_mappings    = $args->{'field_mappings'};
513
    my $modifier_mappings = $args->{'modifier_mappings'};
514
    my $filter_mappings   = $args->{'filter_mappings'};
515
    my $relbumps          = $args->{'relevance_bumps'};
516
    my ( $server, $bib1_mapping );
517
    foreach my $class ( keys %$field_mappings ) {
518
        foreach my $field ( keys %{ $field_mappings->{$class} } ) {
519
            if ( $field_mappings->{$class}->{$field}->{'enabled'} ) {
520
                while ( ( $server, $bib1_mapping ) =
521
                    each
522
                    %{ $field_mappings->{$class}->{$field}->{'bib1_mapping'} } )
523
                {
524
                    $self->add_bib1_field_map(
525
                        $class => $field => $server => $bib1_mapping );
526
                }
527
                $self->add_search_field_alias( $class => $field =>
528
                      $field_mappings->{$class}->{$field}->{'index'} );
529
                foreach my $alias (
530
                    @{ $field_mappings->{$class}->{$field}->{'aliases'} } )
531
                {
532
                    next
533
                      if ( $alias eq
534
                        $field_mappings->{$class}->{$field}->{'index'} );
535
                    $self->add_search_field_alias( $class => $field => $alias );
536
                }
537
            }
538
        }
539
    }
540
    foreach my $modifier ( keys %$modifier_mappings ) {
541
        if ( $modifier_mappings->{$modifier}->{'enabled'} ) {
542
            while ( ( $server, $bib1_mapping ) =
543
                each %{ $modifier_mappings->{$modifier}->{'bib1_mapping'} } )
544
            {
545
                $self->add_bib1_modifier_map(
546
                    $modifier => $server => $bib1_mapping );
547
            }
548
        }
549
    }
550
    foreach my $filter ( keys %$filter_mappings ) {
551
        if ( $filter_mappings->{$filter}->{'enabled'} ) {
552
            while ( ( $server, $bib1_mapping ) =
553
                each %{ $filter_mappings->{$filter}->{'bib1_mapping'} } )
554
            {
555
                if ( $bib1_mapping->{'target_syntax_callback'} eq
556
                    'date_filter_target_callback' )
557
                {
558
                    $bib1_mapping->{'target_syntax_callback'} =
559
                      \&Koha::QueryParser::Driver::PQF::date_filter_target_callback;
560
                }
561
                $self->add_bib1_filter_map(
562
                    $filter => $server => $bib1_mapping );
563
            }
564
        }
565
    }
566
    foreach my $class ( keys %$relbumps ) {
567
        foreach my $field ( keys %{ $relbumps->{$class} } ) {
568
            if ( $relbumps->{$class}->{$field}->{'enabled'} ) {
569
                while ( ( $server, $bib1_mapping ) =
570
                    each %{ $relbumps->{$class}->{$field}->{'bib1_mapping'} } )
571
                {
572
                    $self->add_relevance_bump(
573
                        $class => $field => $server => $bib1_mapping,
574
                        1
575
                    );
576
                }
577
            }
578
        }
579
    }
580
    return $self;
581
}
582
583
=head2 load_config
584
585
  $QParser->load_config($file_name);
586
587
Load a YAML file with a parser configuration. The YAML file should match the following format:
588
589
    ---
590
    field_mappings:
591
      author:
592
        "":
593
          aliases:
594
            - au
595
          bib1_mapping:
596
            biblioserver:
597
              1: 1003
598
          enabled: 1
599
          index: ''
600
          label: ''
601
        conference:
602
          aliases:
603
            - conference
604
            - cfn
605
          bib1_mapping:
606
            biblioserver:
607
              1: 1006
608
          enabled: 1
609
          index: conference
610
          label: Conference
611
    filter_mappings:
612
      acqdate:
613
        bib1_mapping:
614
          biblioserver:
615
            1: Date-of-acquisition
616
            4: 4
617
            target_syntax_callback: date_filter_target_callback
618
        enabled: 1
619
        label: Acqdate
620
    modifier_mappings:
621
      AuthidAsc:
622
        bib1_mapping:
623
          authorityserver:
624
            "": 0
625
            1: Local-Number
626
            7: 1
627
            op: "@or"
628
        enabled: 1
629
        label: AuthidAsc
630
    ...
631
632
=cut
633
634
sub load_config {
635
    my ($self, $file) = @_;
636
    require YAML::Any;
637
    return unless ($file && -f $file);
638
    my $config = YAML::Any::LoadFile($file);
639
    return unless ($config);
640
    $self->initialize($config);
641
    return 1;
642
}
643
644
=head2 TEST_SETUP
645
646
    $QParser->TEST_SETUP
647
648
This routine initializes the QueryParser driver with a reasonable set of
649
defaults. This is intended only for testing. Although such test stubs are
650
generally not included in Koha, this type of test stub is used by other
651
QueryParser implementations, and it seems sensible to maintain consistency
652
as much as possible.
653
654
=cut
655
656
sub TEST_SETUP {
657
    my ($self) = @_;
658
659
    $self->default_search_class( 'keyword' );
660
661
    $self->add_bib1_field_map('keyword' => 'abstract' => 'biblioserver' => { '1' => '62' } );
662
    $self->add_search_field_alias( 'keyword' => 'abstract' => 'ab' );
663
    $self->add_bib1_field_map('keyword' => '' => 'biblioserver' => { '1' => '1016' } );
664
    $self->add_search_field_alias( 'keyword' => '' => 'kw' );
665
    $self->add_bib1_field_map('author' => '' => 'biblioserver' => { '1' => '1003' } );
666
    $self->add_search_field_alias( 'author' => '' => 'au' );
667
    $self->add_bib1_field_map('author' => 'personal' => 'biblioserver' => { '1' => '1004' } );
668
    $self->add_bib1_field_map('author' => 'corporate' => 'biblioserver' => { '1' => '1005' } );
669
    $self->add_search_field_alias( 'author' => 'corporate' => 'cpn' );
670
    $self->add_bib1_field_map('author' => 'conference' => 'biblioserver' => { '1' => '1006' } );
671
    $self->add_search_field_alias( 'author' => 'conference' => 'cfn' );
672
    $self->add_bib1_field_map('keyword' => 'local-classification' => 'biblioserver' => { '1' => '20' } );
673
    $self->add_search_field_alias( 'keyword' => 'local-classification' => 'lcn' );
674
    $self->add_search_field_alias( 'keyword' => 'local-classification' => 'callnum' );
675
    $self->add_bib1_field_map('keyword' => 'bib-level' => 'biblioserver' => { '1' => '1021' } );
676
    $self->add_bib1_field_map('keyword' => 'code-institution' => 'biblioserver' => { '1' => '56' } );
677
    $self->add_bib1_field_map('keyword' => 'language' => 'biblioserver' => { '1' => '54' } );
678
    $self->add_search_field_alias( 'keyword' => 'language' => 'ln' );
679
    $self->add_bib1_field_map('keyword' => 'record-type' => 'biblioserver' => { '1' => '1001' } );
680
    $self->add_search_field_alias( 'keyword' => 'record-type' => 'rtype' );
681
    $self->add_search_field_alias( 'keyword' => 'record-type' => 'mc-rtype' );
682
    $self->add_search_field_alias( 'keyword' => 'record-type' => 'mus' );
683
    $self->add_bib1_field_map('keyword' => 'content-type' => 'biblioserver' => { '1' => '1034' } );
684
    $self->add_search_field_alias( 'keyword' => 'content-type' => 'ctype' );
685
    $self->add_bib1_field_map('keyword' => 'lc-card-number' => 'biblioserver' => { '1' => '9' } );
686
    $self->add_search_field_alias( 'keyword' => 'lc-card-number' => 'lc-card' );
687
    $self->add_bib1_field_map('keyword' => 'local-number' => 'biblioserver' => { '1' => '12' } );
688
    $self->add_search_field_alias( 'keyword' => 'local-number' => 'sn' );
689
    $self->add_bib1_filter_map( 'biblioserver', 'copydate', { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => '30', '4' => '4' });
690
    $self->add_bib1_filter_map( 'biblioserver', 'pubdate', { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => 'pubdate', '4' => '4' });
691
    $self->add_bib1_filter_map( 'biblioserver', 'acqdate', { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => 'Date-of-acquisition', '4' => '4' });
692
    $self->add_bib1_field_map('keyword' => 'isbn' => 'biblioserver' => { '1' => '7' } );
693
    $self->add_search_field_alias( 'keyword' => 'isbn' => 'nb' );
694
    $self->add_bib1_field_map('keyword' => 'issn' => 'biblioserver' => { '1' => '8' } );
695
    $self->add_search_field_alias( 'keyword' => 'issn' => 'ns' );
696
    $self->add_bib1_field_map('keyword' => 'identifier-standard' => 'biblioserver' => { '1' => '1007' } );
697
    $self->add_search_field_alias( 'keyword' => 'identifier-standard' => 'ident' );
698
    $self->add_bib1_field_map('keyword' => 'upc' => 'biblioserver' => { '1' => 'UPC' } );
699
    $self->add_search_field_alias( 'keyword' => 'upc' => 'upc' );
700
    $self->add_bib1_field_map('keyword' => 'ean' => 'biblioserver' => { '1' => 'EAN' } );
701
    $self->add_search_field_alias( 'keyword' => 'ean' => 'ean' );
702
    $self->add_bib1_field_map('keyword' => 'music' => 'biblioserver' => { '1' => 'Music-number' } );
703
    $self->add_search_field_alias( 'keyword' => 'music' => 'music' );
704
    $self->add_bib1_field_map('keyword' => 'stock-number' => 'biblioserver' => { '1' => '1028' } );
705
    $self->add_search_field_alias( 'keyword' => 'stock-number' => 'stock-number' );
706
    $self->add_bib1_field_map('keyword' => 'material-type' => 'biblioserver' => { '1' => '1031' } );
707
    $self->add_search_field_alias( 'keyword' => 'material-type' => 'material-type' );
708
    $self->add_bib1_field_map('keyword' => 'place-publication' => 'biblioserver' => { '1' => '59' } );
709
    $self->add_search_field_alias( 'keyword' => 'place-publication' => 'pl' );
710
    $self->add_bib1_field_map('keyword' => 'personal-name' => 'biblioserver' => { '1' => 'Personal-name' } );
711
    $self->add_search_field_alias( 'keyword' => 'personal-name' => 'pn' );
712
    $self->add_bib1_field_map('keyword' => 'publisher' => 'biblioserver' => { '1' => '1018' } );
713
    $self->add_search_field_alias( 'keyword' => 'publisher' => 'pb' );
714
    $self->add_bib1_field_map('keyword' => 'note' => 'biblioserver' => { '1' => '63' } );
715
    $self->add_search_field_alias( 'keyword' => 'note' => 'nt' );
716
    $self->add_bib1_field_map('keyword' => 'record-control-number' => 'biblioserver' => { '1' => '1045' } );
717
    $self->add_search_field_alias( 'keyword' => 'record-control-number' => 'rcn' );
718
    $self->add_bib1_field_map('subject' => '' => 'biblioserver' => { '1' => '21' } );
719
    $self->add_search_field_alias( 'subject' => '' => 'su' );
720
    $self->add_search_field_alias( 'subject' => '' => 'su-to' );
721
    $self->add_search_field_alias( 'subject' => '' => 'su-geo' );
722
    $self->add_search_field_alias( 'subject' => '' => 'su-ut' );
723
    $self->add_bib1_field_map('subject' => 'name-personal' => 'biblioserver' => { '1' => '1009' } );
724
    $self->add_search_field_alias( 'subject' => 'name-personal' => 'su-na' );
725
    $self->add_bib1_field_map('title' => '' => 'biblioserver' => { '1' => '4' } );
726
    $self->add_search_field_alias( 'title' => '' => 'ti' );
727
    $self->add_bib1_field_map('title' => 'cover' => 'biblioserver' => { '1' => '36' } );
728
    $self->add_search_field_alias( 'title' => 'cover' => 'title-cover' );
729
    $self->add_bib1_field_map('keyword' => 'host-item' => 'biblioserver' => { '1' => '1033' } );
730
    $self->add_bib1_field_map('keyword' => 'video-mt' => 'biblioserver' => { '1' => 'Video-mt' } );
731
    $self->add_bib1_field_map('keyword' => 'graphics-type' => 'biblioserver' => { '1' => 'Graphic-type' } );
732
    $self->add_bib1_field_map('keyword' => 'graphics-support' => 'biblioserver' => { '1' => 'Graphic-support' } );
733
    $self->add_bib1_field_map('keyword' => 'type-of-serial' => 'biblioserver' => { '1' => 'Type-Of-Serial' } );
734
    $self->add_bib1_field_map('keyword' => 'regularity-code' => 'biblioserver' => { '1' => 'Regularity-code' } );
735
    $self->add_bib1_field_map('keyword' => 'material-type' => 'biblioserver' => { '1' => 'Material-type' } );
736
    $self->add_bib1_field_map('keyword' => 'literature-code' => 'biblioserver' => { '1' => 'Literature-Code' } );
737
    $self->add_bib1_field_map('keyword' => 'biography-code' => 'biblioserver' => { '1' => 'Biography-code' } );
738
    $self->add_bib1_field_map('keyword' => 'illustration-code' => 'biblioserver' => { '1' => 'Illustration-code' } );
739
    $self->add_bib1_field_map('title' => 'series' => 'biblioserver' => { '1' => '5' } );
740
    $self->add_search_field_alias( 'title' => 'series' => 'title-series' );
741
    $self->add_search_field_alias( 'title' => 'series' => 'se' );
742
    $self->add_bib1_field_map('title' => 'uniform' => 'biblioserver' => { '1' => 'Title-uniform' } );
743
    $self->add_search_field_alias( 'title' => 'uniform' => 'title-uniform' );
744
    $self->add_bib1_field_map('subject' => 'authority-number' => 'biblioserver' => { '1' => 'Koha-Auth-Number' } );
745
    $self->add_search_field_alias( 'subject' => 'authority-number' => 'an' );
746
    $self->add_bib1_field_map('keyword' => 'control-number' => 'biblioserver' => { '1' => '9001' } );
747
    $self->add_bib1_field_map('keyword' => 'biblionumber' => 'biblioserver' => { '1' => '9002', '5' => '100' } );
748
    $self->add_bib1_field_map('keyword' => 'totalissues' => 'biblioserver' => { '1' => '9003' } );
749
    $self->add_bib1_field_map('keyword' => 'cn-bib-source' => 'biblioserver' => { '1' => '9004' } );
750
    $self->add_bib1_field_map('keyword' => 'cn-bib-sort' => 'biblioserver' => { '1' => '9005' } );
751
    $self->add_bib1_field_map('keyword' => 'itemtype' => 'biblioserver' => { '1' => '9006' } );
752
    $self->add_search_field_alias( 'keyword' => 'itemtype' => 'mc-itemtype' );
753
    $self->add_bib1_field_map('keyword' => 'cn-class' => 'biblioserver' => { '1' => '9007' } );
754
    $self->add_bib1_field_map('keyword' => 'cn-item' => 'biblioserver' => { '1' => '9008' } );
755
    $self->add_bib1_field_map('keyword' => 'cn-prefix' => 'biblioserver' => { '1' => '9009' } );
756
    $self->add_bib1_field_map('keyword' => 'cn-suffix' => 'biblioserver' => { '1' => '9010' } );
757
    $self->add_bib1_field_map('keyword' => 'suppress' => 'biblioserver' => { '1' => '9011' } );
758
    $self->add_bib1_field_map('keyword' => 'id-other' => 'biblioserver' => { '1' => '9012' } );
759
    $self->add_bib1_field_map('keyword' => 'date-entered-on-file' => 'biblioserver' => { '1' => 'date-entered-on-file' } );
760
    $self->add_bib1_field_map('keyword' => 'extent' => 'biblioserver' => { '1' => 'Extent' } );
761
    $self->add_bib1_field_map('keyword' => 'llength' => 'biblioserver' => { '1' => 'llength' } );
762
    $self->add_bib1_field_map('keyword' => 'summary' => 'biblioserver' => { '1' => 'Summary' } );
763
    $self->add_bib1_field_map('keyword' => 'withdrawn' => 'biblioserver' => { '1' => '8001' } );
764
    $self->add_bib1_field_map('keyword' => 'lost' => 'biblioserver' => { '1' => '8002' } );
765
    $self->add_bib1_field_map('keyword' => 'classification-source' => 'biblioserver' => { '1' => '8003' } );
766
    $self->add_bib1_field_map('keyword' => 'materials-specified' => 'biblioserver' => { '1' => '8004' } );
767
    $self->add_bib1_field_map('keyword' => 'damaged' => 'biblioserver' => { '1' => '8005' } );
768
    $self->add_bib1_field_map('keyword' => 'restricted' => 'biblioserver' => { '1' => '8006' } );
769
    $self->add_bib1_field_map('keyword' => 'cn-sort' => 'biblioserver' => { '1' => '8007' } );
770
    $self->add_bib1_field_map('keyword' => 'notforloan' => 'biblioserver' => { '1' => '8008', '4' => '109' } );
771
    $self->add_bib1_field_map('keyword' => 'ccode' => 'biblioserver' => { '1' => '8009' } );
772
    $self->add_search_field_alias( 'keyword' => 'ccode' => 'mc-ccode' );
773
    $self->add_bib1_field_map('keyword' => 'itemnumber' => 'biblioserver' => { '1' => '8010' } );
774
    $self->add_bib1_field_map('keyword' => 'homebranch' => 'biblioserver' => { '1' => 'homebranch' } );
775
    $self->add_search_field_alias( 'keyword' => 'homebranch' => 'branch' );
776
    $self->add_bib1_field_map('keyword' => 'holdingbranch' => 'biblioserver' => { '1' => '8012' } );
777
    $self->add_bib1_field_map('keyword' => 'location' => 'biblioserver' => { '1' => '8013' } );
778
    $self->add_search_field_alias( 'keyword' => 'location' => 'mc-loc' );
779
    $self->add_bib1_field_map('keyword' => 'acqsource' => 'biblioserver' => { '1' => '8015' } );
780
    $self->add_bib1_field_map('keyword' => 'coded-location-qualifier' => 'biblioserver' => { '1' => '8016' } );
781
    $self->add_bib1_field_map('keyword' => 'price' => 'biblioserver' => { '1' => '8017' } );
782
    $self->add_bib1_field_map('keyword' => 'stocknumber' => 'biblioserver' => { '1' => '1062' } );
783
    $self->add_search_field_alias( 'keyword' => 'stocknumber' => 'inv' );
784
    $self->add_bib1_field_map('keyword' => 'stack' => 'biblioserver' => { '1' => '8018' } );
785
    $self->add_bib1_field_map('keyword' => 'issues' => 'biblioserver' => { '1' => '8019' } );
786
    $self->add_bib1_field_map('keyword' => 'renewals' => 'biblioserver' => { '1' => '8020' } );
787
    $self->add_bib1_field_map('keyword' => 'reserves' => 'biblioserver' => { '1' => '8021' } );
788
    $self->add_bib1_field_map('keyword' => 'local-classification' => 'biblioserver' => { '1' => '8022' } );
789
    $self->add_bib1_field_map('keyword' => 'barcode' => 'biblioserver' => { '1' => '8023' } );
790
    $self->add_search_field_alias( 'keyword' => 'barcode' => 'bc' );
791
    $self->add_bib1_field_map('keyword' => 'onloan' => 'biblioserver' => { '1' => '8024' } );
792
    $self->add_bib1_field_map('keyword' => 'datelastseen' => 'biblioserver' => { '1' => '8025' } );
793
    $self->add_bib1_field_map('keyword' => 'datelastborrowed' => 'biblioserver' => { '1' => '8026' } );
794
    $self->add_bib1_field_map('keyword' => 'copynumber' => 'biblioserver' => { '1' => '8027' } );
795
    $self->add_bib1_field_map('keyword' => 'uri' => 'biblioserver' => { '1' => '8028' } );
796
    $self->add_bib1_field_map('keyword' => 'replacementprice' => 'biblioserver' => { '1' => '8029' } );
797
    $self->add_bib1_field_map('keyword' => 'replacementpricedate' => 'biblioserver' => { '1' => '8030' } );
798
    $self->add_bib1_field_map('keyword' => 'itype' => 'biblioserver' => { '1' => '8031' } );
799
    $self->add_search_field_alias( 'keyword' => 'itype' => 'mc-itype' );
800
    $self->add_bib1_field_map('keyword' => 'ff8-22' => 'biblioserver' => { '1' => '8822' } );
801
    $self->add_bib1_field_map('keyword' => 'ff8-23' => 'biblioserver' => { '1' => '8823' } );
802
    $self->add_bib1_field_map('keyword' => 'ff8-34' => 'biblioserver' => { '1' => '8834' } );
803
# Audience
804
    $self->add_bib1_field_map('keyword' => 'audience' => 'biblioserver' => { '1' => '8822' } );
805
    $self->add_search_field_alias( 'keyword' => 'audience' => 'aud' );
806
807
# Content and Literary form
808
    $self->add_bib1_field_map('keyword' => 'fiction' => 'biblioserver' => { '1' => '8833' } );
809
    $self->add_search_field_alias( 'keyword' => 'fiction' => 'fic' );
810
    $self->add_bib1_field_map('keyword' => 'biography' => 'biblioserver' => { '1' => '8834' } );
811
    $self->add_search_field_alias( 'keyword' => 'biography' => 'bio' );
812
813
# Format
814
    $self->add_bib1_field_map('keyword' => 'format' => 'biblioserver' => { '1' => '8823' } );
815
# format used as a limit FIXME: needed?
816
    $self->add_bib1_field_map('keyword' => 'l-format' => 'biblioserver' => { '1' => '8703' } );
817
818
    $self->add_bib1_field_map('keyword' => 'illustration-code' => 'biblioserver' => { '1' => 'Illustration-code ' } );
819
820
# Lexile Number
821
    $self->add_bib1_field_map('keyword' => 'lex' => 'biblioserver' => { '1' => '9903 r=r' } );
822
823
#Accelerated Reader Level
824
    $self->add_bib1_field_map('keyword' => 'arl' => 'biblioserver' => { '1' => '9904 r=r' } );
825
826
#Accelerated Reader Point
827
    $self->add_bib1_field_map('keyword' => 'arp' => 'biblioserver' => { '1' => '9013 r=r' } );
828
829
# Curriculum
830
    $self->add_bib1_field_map('keyword' => 'curriculum' => 'biblioserver' => { '1' => '9658' } );
831
832
## Statuses
833
    $self->add_bib1_field_map('keyword' => 'popularity' => 'biblioserver' => { '1' => 'issues' } );
834
835
## Type Limits
836
    $self->add_bib1_field_map('keyword' => 'dt-bks' => 'biblioserver' => { '1' => '8700' } );
837
    $self->add_bib1_field_map('keyword' => 'dt-vis' => 'biblioserver' => { '1' => '8700' } );
838
    $self->add_bib1_field_map('keyword' => 'dt-sr' => 'biblioserver' => { '1' => '8700' } );
839
    $self->add_bib1_field_map('keyword' => 'dt-cf' => 'biblioserver' => { '1' => '8700' } );
840
    $self->add_bib1_field_map('keyword' => 'dt-map' => 'biblioserver' => { '1' => '8700' } );
841
842
    $self->add_bib1_field_map('keyword' => 'name' => 'biblioserver' => { '1' => '1002' } );
843
    $self->add_bib1_field_map('keyword' => 'item' => 'biblioserver' => { '1' => '9520' } );
844
    $self->add_bib1_field_map('keyword' => 'host-item-number' => 'biblioserver' => { '1' => '8911' } );
845
    $self->add_search_field_alias( 'keyword' => 'host-item-number' => 'hi' );
846
847
    $self->add_bib1_field_map('keyword' => 'alwaysmatch' => 'biblioserver' => { '1' => '_ALLRECORDS', '2' => '103' } );
848
    $self->add_bib1_field_map('subject' => 'complete' => 'biblioserver' => { '1' => '21', '3' => '1', '4' => '1', '5' => '100', '6' => '3' } );
849
850
    $self->add_bib1_modifier_map('relevance' => 'biblioserver' => { '2' => '102' } );
851
    $self->add_bib1_modifier_map('title-sort-za' => 'biblioserver' => { '7' => '2', '1' => '36', '' => '0', 'op' => '@or' } );
852
    $self->add_bib1_modifier_map('title-sort-az' => 'biblioserver' => { '7' => '1', '1' => '36', '' => '0', 'op' => '@or' } );
853
    $self->add_bib1_modifier_map('relevance_dsc' => 'biblioserver' => { '2' => '102' } );
854
    $self->add_bib1_modifier_map('title_dsc' => 'biblioserver' => { '7' => '2', '1' => '4', '' => '0', 'op' => '@or' } );
855
    $self->add_bib1_modifier_map('title_asc' => 'biblioserver' => { '7' => '1', '1' => '4', '' => '0', 'op' => '@or' } );
856
    $self->add_bib1_modifier_map('author_asc' => 'biblioserver' => { '7' => '2', '1' => '1003', '' => '0', 'op' => '@or' } );
857
    $self->add_bib1_modifier_map('author_dsc' => 'biblioserver' => { '7' => '1', '1' => '1003', '' => '0', 'op' => '@or' } );
858
    $self->add_bib1_modifier_map('popularity_asc' => 'biblioserver' => { '7' => '2', '1' => '9003', '' => '0', 'op' => '@or' } );
859
    $self->add_bib1_modifier_map('popularity_dsc' => 'biblioserver' => { '7' => '1', '1' => '9003', '' => '0', 'op' => '@or' } );
860
    $self->add_bib1_modifier_map('call_number_asc' => 'biblioserver' => { '7' => '2', '1' => '8007', '' => '0', 'op' => '@or' } );
861
    $self->add_bib1_modifier_map('call_number_dsc' => 'biblioserver' => { '7' => '1', '1' => '8007', '' => '0', 'op' => '@or' } );
862
    $self->add_bib1_modifier_map('pubdate_asc' => 'biblioserver' => { '7' => '2', '1' => '31', '' => '0', 'op' => '@or' } );
863
    $self->add_bib1_modifier_map('pubdate_dsc' => 'biblioserver' => { '7' => '1', '1' => '31', '' => '0', 'op' => '@or' } );
864
    $self->add_bib1_modifier_map('acqdate_asc' => 'biblioserver' => { '7' => '2', '1' => '32', '' => '0', 'op' => '@or' } );
865
    $self->add_bib1_modifier_map('acqdate_dsc' => 'biblioserver' => { '7' => '1', '1' => '32', '' => '0', 'op' => '@or' } );
866
867
    $self->add_bib1_modifier_map('title_za' => 'biblioserver' => { '7' => '2', '1' => '4', '' => '0', 'op' => '@or' } );
868
    $self->add_bib1_modifier_map('title_az' => 'biblioserver' => { '7' => '1', '1' => '4', '' => '0', 'op' => '@or' } );
869
    $self->add_bib1_modifier_map('author_za' => 'biblioserver' => { '7' => '2', '1' => '1003', '' => '0', 'op' => '@or' } );
870
    $self->add_bib1_modifier_map('author_az' => 'biblioserver' => { '7' => '1', '1' => '1003', '' => '0', 'op' => '@or' } );
871
    $self->add_bib1_modifier_map('ascending' => 'biblioserver' => { '7' => '1' } );
872
    $self->add_bib1_modifier_map('descending' => 'biblioserver' => { '7' => '2' } );
873
874
    $self->add_bib1_field_map('title' => 'exacttitle' => 'biblioserver' => { '1' => '4', '4' => '1', '6' => '3' } );
875
    $self->add_search_field_alias( 'title' => 'exacttitle' => 'ti,ext' );
876
    $self->add_bib1_field_map('author' => 'exactauthor' => 'biblioserver' => { '1' => '1003', '4' => '1', '6' => '3' } );
877
    $self->add_search_field_alias( 'author' => 'exactauthor' => 'au,ext' );
878
879
    $self->add_bib1_field_map('subject' => 'headingmain' => 'authorityserver' => { '1' => 'Heading-Main' } );
880
    $self->add_bib1_field_map('subject' => 'heading' => 'authorityserver' => { '1' => 'Heading' } );
881
    $self->add_bib1_field_map('subject' => 'matchheading' => 'authorityserver' => { '1' => 'Match-heading' } );
882
    $self->add_bib1_field_map('subject' => 'seefrom' => 'authorityserver' => { '1' => 'Match-heading-see-from' } );
883
    $self->add_bib1_field_map('subject' => '' => 'authorityserver' => { '1' => 'Match-heading' } );
884
    $self->add_bib1_field_map('keyword' => 'alwaysmatch' => 'authorityserver' => { '1' => '_ALLRECORDS', '2' => '103' } );
885
    $self->add_bib1_field_map('keyword' => 'match' => 'authorityserver' => { '1' => 'Match' } );
886
    $self->add_bib1_field_map('keyword' => 'thesaurus' => 'authorityserver' => { '1' => 'Subject-heading-thesaurus' } );
887
    $self->add_bib1_field_map('keyword' => 'authtype' => 'authorityserver' => { '1' => 'authtype', '5' => '100' } );
888
    $self->add_bib1_field_map('keyword' => '' => 'authorityserver' => { '1' => 'Any' } );
889
    $self->add_search_field_alias( 'subject' => 'headingmain' => 'mainmainentry' );
890
    $self->add_search_field_alias( 'subject' => 'heading' => 'mainentry' );
891
    $self->add_search_field_alias( 'subject' => 'heading' => 'he' );
892
    $self->add_search_field_alias( 'subject' => 'matchheading' => 'match-heading' );
893
    $self->add_search_field_alias( 'keyword' => '' => 'any' );
894
    $self->add_search_field_alias( 'keyword' => 'match' => 'match' );
895
    $self->add_search_field_alias( 'subject' => 'seefrom' => 'see-from' );
896
    $self->add_search_field_alias( 'keyword' => 'thesaurus' => 'thesaurus' );
897
    $self->add_search_field_alias( 'keyword' => 'alwaysmatch' => 'all' );
898
    $self->add_search_field_alias( 'keyword' => 'authtype' => 'authtype' );
899
    $self->add_search_field_alias( 'keyword' => 'authtype' => 'at' );
900
901
    $self->add_bib1_field_map('subject' => 'start' => 'authorityserver' => { '3' => '2', '4' => '1', '5' => '1' } );
902
    $self->add_bib1_field_map('subject' => 'exact' => 'authorityserver' => { '4' => '1', '5' => '100', '6' => '3' } );
903
904
    $self->add_bib1_modifier_map('HeadingAsc' => 'authorityserver' => { '7' => '1', '1' => 'Heading', '' => '0', 'op' => '@or' } );
905
    $self->add_bib1_modifier_map('HeadingDsc' => 'authorityserver' => { '7' => '2', '1' => 'Heading', '' => '0', 'op' => '@or' } );
906
    $self->add_bib1_modifier_map('AuthidAsc' => 'authorityserver' => { '7' => '1', '1' => 'Local-Number', '' => '0', 'op' => '@or' } );
907
    $self->add_bib1_modifier_map('AuthidDsc' => 'authorityserver' => { '7' => '2', '1' => 'Local-Number', '' => '0', 'op' => '@or' } );
908
    $self->add_bib1_modifier_map('Relevance' => 'authorityserver' => { '2' => '102' } );
909
910
    return $self;
911
}
912
913
1;
(-)a/Koha/QueryParser/Driver/PQF/Util.pm (+22 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF::Util;
2
use Scalar::Util qw(looks_like_number);
3
4
use strict;
5
use warnings;
6
7
sub attributes_to_attr_string {
8
    my ($attributes) = @_;
9
    my $attr_string = '';
10
    my $key;
11
    my $value;
12
    while (($key, $value) = each(%$attributes)) {
13
        next unless looks_like_number($key);
14
        $attr_string .= ' @attr ' . $key . '=' . $value . ' ';
15
    }
16
    $attr_string =~ s/^\s*//;
17
    $attr_string =~ s/\s*$//;
18
    $attr_string .= ' ' . $attributes->{''} if defined $attributes->{''};
19
    return $attr_string;
20
}
21
22
1;
(-)a/Koha/QueryParser/Driver/PQF/query_plan.pm (+46 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF::query_plan;
2
use base 'OpenILS::QueryParser::query_plan';
3
4
use strict;
5
use warnings;
6
7
=head2 Koha::QueryParser::Driver::PQF::query_plan::target_syntax
8
9
    my $pqf = $query_plan->target_syntax($server);
10
11
Transforms an OpenILS::QueryParser::query_plan object into PQF. Do not use directly.
12
13
=cut
14
15
sub target_syntax {
16
    my ($self, $server) = @_;
17
    my $pqf = '';
18
    my $node_pqf;
19
    my $node_count = 0;
20
21
    for my $node ( @{$self->query_nodes} ) {
22
23
        if (ref($node)) {
24
            $node_pqf = $node->target_syntax($server);
25
            $node_count++ if $node_pqf;
26
            $pqf .= $node_pqf;
27
        }
28
    }
29
    $pqf = ($self->joiner eq '|' ? ' @or ' : ' @and ') x ($node_count - 1) . $pqf;
30
    $node_count = ($node_count ? '1' : '0');
31
    for my $node ( @{$self->filters} ) {
32
        if (ref($node)) {
33
            $node_pqf = $node->target_syntax($server);
34
            $node_count++ if $node_pqf;
35
            $pqf .= $node_pqf;
36
        }
37
    }
38
    $pqf = ($self->joiner eq '|' ? ' @or ' : ' @and ') x ($node_count - 1) . $pqf;
39
    foreach my $modifier ( @{$self->modifiers} ) {
40
        my $modifierpqf = $modifier->target_syntax($server, $self);
41
        $pqf = $modifierpqf . ' ' . $pqf if $modifierpqf;
42
    }
43
    return ($self->negate ? '@not @attr 1=_ALLRECORDS @attr 2=103 "" ' : '') . $pqf;
44
}
45
46
1;
(-)a/Koha/QueryParser/Driver/PQF/query_plan/facet.pm (+22 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF::query_plan::facet;
2
use base 'OpenILS::QueryParser::query_plan::facet';
3
4
use strict;
5
use warnings;
6
7
=head2 Koha::QueryParser::Driver::PQF::query_plan::facet::target_syntax
8
9
    my $pqf = $facet->target_syntax($server);
10
11
Transforms an OpenILS::QueryParser::query_plan::facet object into PQF. Do not use
12
directly.
13
14
=cut
15
16
sub target_syntax {
17
    my ($self, $server) = @_;
18
19
    return '';
20
}
21
22
1;
(-)a/Koha/QueryParser/Driver/PQF/query_plan/filter.pm (+27 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF::query_plan::filter;
2
use base 'OpenILS::QueryParser::query_plan::filter';
3
4
use strict;
5
use warnings;
6
7
=head2 Koha::QueryParser::Driver::PQF::query_plan::filter::target_syntax
8
9
    my $pqf = $filter->target_syntax($server);
10
11
Transforms an OpenILS::QueryParser::query_plan::filter object into PQF. Do not use
12
directly.
13
14
=cut
15
16
sub target_syntax {
17
    my ($self, $server) = @_;
18
    my $attributes = $self->plan->QueryParser->bib1_mapping_by_name( 'filter', $self->name, $server );
19
20
    if ($attributes->{'target_syntax_callback'}) {
21
        return $attributes->{'target_syntax_callback'}->($self->plan->QueryParser, $self->name, $self->args, $self->negate, $server);
22
    } else {
23
        return '';
24
    }
25
}
26
27
1;
(-)a/Koha/QueryParser/Driver/PQF/query_plan/modifier.pm (+27 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF::query_plan::modifier;
2
use base 'OpenILS::QueryParser::query_plan::modifier';
3
4
use strict;
5
use warnings;
6
7
=head2 Koha::QueryParser::Driver::PQF::query_plan::modifier::target_syntax
8
9
    my $pqf = $modifier->target_syntax($server, $query_plan);
10
11
Transforms an OpenILS::QueryParser::query_plan::modifier object into PQF. Do not use
12
directly. The second argument points ot the query_plan, since modifiers do
13
not have a reference to their parent query_plan.
14
15
=cut
16
17
sub target_syntax {
18
    my ($self, $server, $query_plan) = @_;
19
    my $pqf = '';
20
    my @fields;
21
22
    my $attributes = $query_plan->QueryParser->bib1_mapping_by_name('modifier', $self->name, $server);
23
    $pqf = ($attributes->{'op'} ? $attributes->{'op'} . ' ' : '') . ($self->negate ? '@not @attr 1=_ALLRECORDS @attr 2=103 "" ' : '') . $attributes->{'attr_string'};
24
    return $pqf;
25
}
26
27
1;
(-)a/Koha/QueryParser/Driver/PQF/query_plan/node.pm (+76 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF::query_plan::node;
2
use base 'OpenILS::QueryParser::query_plan::node';
3
4
use strict;
5
use warnings;
6
7
=head2 Koha::QueryParser::Driver::PQF::query_plan::node::target_syntax
8
9
    my $pqf = $node->target_syntax($server);
10
11
Transforms an OpenILS::QueryParser::query_plan::node object into PQF. Do not use directly.
12
13
=cut
14
15
sub target_syntax {
16
    my ($self, $server) = @_;
17
    my $pqf = '';
18
    my $atom_content;
19
    my $atom_count = 0;
20
    my @fields = ();
21
    my $fieldobj;
22
    my $relbump;
23
24
    if (scalar(@{$self->fields})) {
25
        foreach my $field (@{$self->fields}) {
26
            $fieldobj = $self->plan->QueryParser->bib1_mapping_by_name('field', $self->classname, $field, $server);
27
            $relbump = $self->plan->QueryParser->bib1_mapping_by_name('relevance_bump', $self->classname, $field, $server);
28
            if ($relbump) {
29
                $fieldobj->{'attr_string'} .= ' ' . $relbump->{'attr_string'};
30
            }
31
            push @fields, $fieldobj unless ($field eq $self->classname && scalar @fields);
32
        }
33
    } else {
34
        $fieldobj = $self->plan->QueryParser->bib1_mapping_by_name('field', $self->classname, $self->classname, $server);
35
        my $relbumps = $self->plan->QueryParser->bib1_mapping_by_name('relevance_bump', $self->classname, '', $server);
36
        push @fields, $fieldobj;
37
        if ($relbumps) {
38
            foreach my $field (keys %$relbumps) {
39
                $relbump = $relbumps->{$field};
40
                $fieldobj = $self->plan->QueryParser->bib1_mapping_by_name('field', $relbump->{'classname'}, $relbump->{'field'}, $server);
41
                $fieldobj->{'attr_string'} ||= '';
42
                $fieldobj->{'attr_string'} .= ' ' . $relbump->{$server}{'attr_string'} if $relbump->{$server}{'attr_string'};
43
                push @fields, $fieldobj;
44
            }
45
        }
46
    }
47
48
    if (@{$self->phrases}) {
49
        foreach my $phrase (@{$self->phrases}) {
50
            if ($phrase) {
51
                $pqf .= ' @or ' x (scalar(@fields) - 1);
52
                foreach my $attributes (@fields) {
53
                    $pqf .= $attributes->{'attr_string'} . ($attributes->{'4'} ? '' : ' @attr 4=1') . ' "' . $phrase . '" ';
54
                }
55
                $atom_count++;
56
            }
57
        }
58
    } else {
59
        foreach my $atom (@{$self->query_atoms}) {
60
            if (ref($atom)) {
61
                $atom_content = $atom->target_syntax($server);
62
                if ($atom_content) {
63
                    $pqf .= ' @or ' x (scalar(@fields) - 1);
64
                    foreach my $attributes (@fields) {
65
                        $pqf .= $attributes->{'attr_string'} . ($attributes->{'4'} ? '' : ' @attr 4=6 ') . $atom_content . ' ';
66
                    }
67
                    $atom_count++;
68
                }
69
            }
70
        }
71
    }
72
    $pqf = (OpenILS::QueryParser::_util::default_joiner eq '|' ? ' @or ' : ' @and ') x ($atom_count - 1) . $pqf;
73
    return ($self->negate ? '@not @attr 1=_ALLRECORDS @attr 2=103 "" ' : '') . $pqf;
74
}
75
76
1;
(-)a/Koha/QueryParser/Driver/PQF/query_plan/node/atom.pm (+22 lines)
Line 0 Link Here
1
package Koha::QueryParser::Driver::PQF::query_plan::node::atom;
2
use base 'OpenILS::QueryParser::query_plan::node::atom';
3
4
use strict;
5
use warnings;
6
7
=head2 Koha::QueryParser::Driver::PQF::query_plan::node::atom::target_syntax
8
9
    my $pqf = $atom->target_syntax($server);
10
11
Transforms an OpenILS::QueryParser::query_plan::node::atom object into PQF. Do not use
12
directly.
13
14
=cut
15
16
sub target_syntax {
17
    my ($self, $server) = @_;
18
19
    return ' "' .  $self->content . '" ';
20
}
21
22
1;
(-)a/etc/searchengine/queryparser.yaml (+1487 lines)
Line 0 Link Here
1
---
2
field_mappings:
3
  author:
4
    author:
5
      aliases:
6
        - au
7
      bib1_mapping:
8
        biblioserver:
9
          1: 1003
10
      enabled: 1
11
      index: ''
12
      label: ''
13
    conference:
14
      aliases:
15
        - conference
16
        - cfn
17
      bib1_mapping:
18
        biblioserver:
19
          1: 1006
20
      enabled: 1
21
      index: conference
22
      label: Conference
23
    corporate:
24
      aliases:
25
        - corporate
26
        - cpn
27
      bib1_mapping:
28
        biblioserver:
29
          1: 1005
30
      enabled: 1
31
      index: corporate
32
      label: Corporate
33
    exactauthor:
34
      aliases:
35
        - exactauthor
36
        - au,ext
37
      bib1_mapping:
38
        biblioserver:
39
          1: 1003
40
          4: 1
41
          6: 3
42
      enabled: 1
43
      index: exactauthor
44
      label: Exactauthor
45
    personal:
46
      aliases:
47
        - personal
48
      bib1_mapping:
49
        biblioserver:
50
          1: 1004
51
      enabled: 1
52
      index: personal
53
      label: Personal
54
  keyword:
55
    keyword:
56
      aliases:
57
        - any
58
        - kw
59
      bib1_mapping:
60
        authorityserver:
61
          1: Any
62
        biblioserver:
63
          1: 1016
64
      enabled: 1
65
      index: 'keyword'
66
      label: 'Keyword'
67
    abstract:
68
      aliases:
69
        - abstract
70
        - ab
71
      bib1_mapping:
72
        biblioserver:
73
          1: 62
74
      enabled: 1
75
      index: abstract
76
      label: Abstract
77
    acqsource:
78
      aliases:
79
        - acqsource
80
      bib1_mapping:
81
        biblioserver:
82
          1: 8015
83
      enabled: 1
84
      index: acqsource
85
      label: Acqsource
86
    alwaysmatch:
87
      aliases:
88
        - alwaysmatch
89
        - all
90
      bib1_mapping:
91
        authorityserver:
92
          1: _ALLRECORDS
93
          2: 103
94
        biblioserver:
95
          1: _ALLRECORDS
96
          2: 103
97
      enabled: 1
98
      index: alwaysmatch
99
      label: Alwaysmatch
100
    arl:
101
      aliases:
102
        - arl
103
      bib1_mapping:
104
        biblioserver:
105
          1: 9904 r=r
106
      enabled: 1
107
      index: arl
108
      label: Arl
109
    arp:
110
      aliases:
111
        - arp
112
      bib1_mapping:
113
        biblioserver:
114
          1: 9013 r=r
115
      enabled: 1
116
      index: arp
117
      label: Arp
118
    audience:
119
      aliases:
120
        - audience
121
        - aud
122
      bib1_mapping:
123
        biblioserver:
124
          1: 8822
125
      enabled: 1
126
      index: audience
127
      label: Audience
128
    authtype:
129
      aliases:
130
        - authtype
131
        - at
132
      bib1_mapping:
133
        authorityserver:
134
          1: authtype
135
          5: 100
136
      enabled: 1
137
      index: authtype
138
      label: Authtype
139
    authorext:
140
      alias: []
141
      bib1_mapping:
142
        biblioserver:
143
          1: 1003
144
          4: 1
145
          6: 2
146
      enabled: 1
147
      index: author
148
      label: Authorkw
149
    authorkw:
150
      alias: []
151
      bib1_mapping:
152
        biblioserver:
153
          1: 1003
154
      enabled: 1
155
      index: author
156
      label: Authorkw
157
    barcode:
158
      aliases:
159
        - barcode
160
        - bc
161
      bib1_mapping:
162
        biblioserver:
163
          1: 8023
164
      enabled: 1
165
      index: barcode
166
      label: Barcode
167
    bib-level:
168
      bib1_mapping:
169
        biblioserver:
170
          1: 1021
171
      enabled: 1
172
      index: bib-level
173
      aliases:
174
        - bib-level
175
      label: Bib-level
176
    biblionumber:
177
      bib1_mapping:
178
        biblioserver:
179
          1: 9002
180
          5: 100
181
      enabled: 1
182
      index: biblionumber
183
      aliases:
184
        - biblionumber
185
      label: Biblionumber
186
    biography:
187
      bib1_mapping:
188
        biblioserver:
189
          1: 8834
190
      enabled: 1
191
      index: biography
192
      aliases:
193
        - biography
194
        - bio
195
      label: Biography
196
    biography-code:
197
      bib1_mapping:
198
        biblioserver:
199
          1: Biography-code
200
      enabled: 1
201
      index: biography-code
202
      aliases:
203
        - biography-code
204
      label: Biography-code
205
    ccode:
206
      bib1_mapping:
207
        biblioserver:
208
          1: 8009
209
      enabled: 1
210
      index: ccode
211
      aliases:
212
        - ccode
213
        - mc-ccode
214
      label: Ccode
215
    classification-source:
216
      bib1_mapping:
217
        biblioserver:
218
          1: 8003
219
      enabled: 1
220
      index: classification-source
221
      aliases:
222
        - classification-source
223
      label: Classification-source
224
    cn-bib-sort:
225
      bib1_mapping:
226
        biblioserver:
227
          1: 9005
228
      enabled: 1
229
      index: cn-bib-sort
230
      aliases:
231
        - cn-bib-sort
232
      label: Cn-bib-sort
233
    cn-bib-source:
234
      bib1_mapping:
235
        biblioserver:
236
          1: 9004
237
      enabled: 1
238
      index: cn-bib-source
239
      aliases:
240
        - cn-bib-source
241
      label: Cn-bib-source
242
    cn-class:
243
      bib1_mapping:
244
        biblioserver:
245
          1: 9007
246
      enabled: 1
247
      index: cn-class
248
      aliases:
249
        - cn-class
250
      label: Cn-class
251
    cn-item:
252
      bib1_mapping:
253
        biblioserver:
254
          1: 9008
255
      enabled: 1
256
      index: cn-item
257
      aliases:
258
        - cn-item
259
      label: Cn-item
260
    cn-prefix:
261
      bib1_mapping:
262
        biblioserver:
263
          1: 9009
264
      enabled: 1
265
      index: cn-prefix
266
      aliases:
267
        - cn-prefix
268
      label: Cn-prefix
269
    cn-sort:
270
      bib1_mapping:
271
        biblioserver:
272
          1: 8007
273
      enabled: 1
274
      index: cn-sort
275
      aliases:
276
        - cn-sort
277
      label: Cn-sort
278
    cn-suffix:
279
      bib1_mapping:
280
        biblioserver:
281
          1: 9010
282
      enabled: 1
283
      index: cn-suffix
284
      aliases:
285
        - cn-suffix
286
      label: Cn-suffix
287
    code-institution:
288
      bib1_mapping:
289
        biblioserver:
290
          1: 56
291
      enabled: 1
292
      index: code-institution
293
      aliases:
294
        - code-institution
295
      label: Code-institution
296
    coded-location-qualifier:
297
      bib1_mapping:
298
        biblioserver:
299
          1: 8016
300
      enabled: 1
301
      index: coded-location-qualifier
302
      aliases:
303
        - coded-location-qualifier
304
      label: Coded-location-qualifier
305
    content-type:
306
      bib1_mapping:
307
        biblioserver:
308
          1: 1034
309
      enabled: 1
310
      index: content-type
311
      aliases:
312
        - content-type
313
        - ctype
314
      label: Content-type
315
    control-number:
316
      bib1_mapping:
317
        biblioserver:
318
          1: 9001
319
      enabled: 1
320
      index: control-number
321
      aliases:
322
        - control-number
323
      label: Control-number
324
    copynumber:
325
      bib1_mapping:
326
        biblioserver:
327
          1: 8027
328
      enabled: 1
329
      index: copynumber
330
      aliases:
331
        - copynumber
332
      label: Copynumber
333
    curriculum:
334
      bib1_mapping:
335
        biblioserver:
336
          1: 9658
337
      enabled: 1
338
      index: curriculum
339
      aliases:
340
        - curriculum
341
      label: Curriculum
342
    damaged:
343
      bib1_mapping:
344
        biblioserver:
345
          1: 8005
346
      enabled: 1
347
      index: damaged
348
      aliases:
349
        - damaged
350
      label: Damaged
351
    date-entered-on-file:
352
      bib1_mapping:
353
        biblioserver:
354
          1: date-entered-on-file
355
      enabled: 1
356
      index: date-entered-on-file
357
      aliases:
358
        - date-entered-on-file
359
      label: Date-entered-on-file
360
    datelastborrowed:
361
      bib1_mapping:
362
        biblioserver:
363
          1: 8026
364
      enabled: 1
365
      index: datelastborrowed
366
      aliases:
367
        - datelastborrowed
368
      label: Datelastborrowed
369
    datelastseen:
370
      bib1_mapping:
371
        biblioserver:
372
          1: 8025
373
      enabled: 1
374
      index: datelastseen
375
      aliases:
376
        - datelastseen
377
      label: Datelastseen
378
    dt-bks:
379
      bib1_mapping:
380
        biblioserver:
381
          1: 8700
382
      enabled: 1
383
      index: dt-bks
384
      aliases:
385
        - dt-bks
386
      label: Dt-bks
387
    dt-cf:
388
      bib1_mapping:
389
        biblioserver:
390
          1: 8700
391
      enabled: 1
392
      index: dt-cf
393
      aliases:
394
        - dt-cf
395
      label: Dt-cf
396
    dt-map:
397
      bib1_mapping:
398
        biblioserver:
399
          1: 8700
400
      enabled: 1
401
      index: dt-map
402
      aliases:
403
        - dt-map
404
      label: Dt-map
405
    dt-sr:
406
      bib1_mapping:
407
        biblioserver:
408
          1: 8700
409
      enabled: 1
410
      index: dt-sr
411
      aliases:
412
        - dt-sr
413
      label: Dt-sr
414
    dt-vis:
415
      bib1_mapping:
416
        biblioserver:
417
          1: 8700
418
      enabled: 1
419
      index: dt-vis
420
      aliases:
421
        - dt-vis
422
      label: Dt-vis
423
    ean:
424
      bib1_mapping:
425
        biblioserver:
426
          1: EAN
427
      enabled: 1
428
      index: ean
429
      aliases:
430
        - ean
431
      label: Ean
432
    extent:
433
      bib1_mapping:
434
        biblioserver:
435
          1: Extent
436
      enabled: 1
437
      index: extent
438
      aliases:
439
        - extent
440
      label: Extent
441
    ff8-22:
442
      bib1_mapping:
443
        biblioserver:
444
          1: 8822
445
      enabled: 1
446
      index: ff8-22
447
      aliases:
448
        - ff8-22
449
      label: Ff8-22
450
    ff8-23:
451
      bib1_mapping:
452
        biblioserver:
453
          1: 8823
454
      enabled: 1
455
      index: ff8-23
456
      aliases:
457
        - ff8-23
458
      label: Ff8-23
459
    ff8-34:
460
      bib1_mapping:
461
        biblioserver:
462
          1: 8834
463
      enabled: 1
464
      index: ff8-34
465
      aliases:
466
        - ff8-34
467
      label: Ff8-34
468
    fiction:
469
      bib1_mapping:
470
        biblioserver:
471
          1: 8833
472
      enabled: 1
473
      index: fiction
474
      aliases:
475
        - fiction
476
        - fic
477
      label: Fiction
478
    format:
479
      bib1_mapping:
480
        biblioserver:
481
          1: 8823
482
      enabled: 1
483
      index: format
484
      aliases:
485
        - format
486
      label: Format
487
    graphics-support:
488
      bib1_mapping:
489
        biblioserver:
490
          1: Graphic-support
491
      enabled: 1
492
      index: graphics-support
493
      aliases:
494
        - graphics-support
495
      label: Graphics-support
496
    graphics-type:
497
      bib1_mapping:
498
        biblioserver:
499
          1: Graphic-type
500
      enabled: 1
501
      index: graphics-type
502
      aliases:
503
        - graphics-type
504
      label: Graphics-type
505
    holdingbranch:
506
      bib1_mapping:
507
        biblioserver:
508
          1: 8012
509
      enabled: 1
510
      index: holdingbranch
511
      aliases:
512
        - holdingbranch
513
      label: Holdingbranch
514
    homebranch:
515
      bib1_mapping:
516
        biblioserver:
517
          1: homebranch
518
      enabled: 1
519
      index: homebranch
520
      aliases:
521
        - homebranch
522
        - branch
523
      label: Homebranch
524
    host-item:
525
      bib1_mapping:
526
        biblioserver:
527
          1: 1033
528
      enabled: 1
529
      index: host-item
530
      aliases:
531
        - host-item
532
      label: Host-item
533
    host-item-number:
534
      bib1_mapping:
535
        biblioserver:
536
          1: 8911
537
      enabled: 1
538
      index: host-item-number
539
      aliases:
540
        - host-item-number
541
        - hi
542
      label: Host-item-number
543
    id-other:
544
      bib1_mapping:
545
        biblioserver:
546
          1: 9012
547
      enabled: 1
548
      index: id-other
549
      aliases:
550
        - id-other
551
      label: Id-other
552
    identifier-standard:
553
      bib1_mapping:
554
        biblioserver:
555
          1: 1007
556
      enabled: 1
557
      index: identifier-standard
558
      aliases:
559
        - identifier-standard
560
        - ident
561
      label: Identifier-standard
562
    illustration-code:
563
      bib1_mapping:
564
        biblioserver:
565
          1: "Illustration-code "
566
      enabled: 1
567
      index: illustration-code
568
      aliases:
569
        - illustration-code
570
      label: Illustration-code
571
    isbn:
572
      bib1_mapping:
573
        biblioserver:
574
          1: 7
575
      enabled: 1
576
      index: isbn
577
      aliases:
578
        - isbn
579
        - nb
580
      label: Isbn
581
    issn:
582
      bib1_mapping:
583
        biblioserver:
584
          1: 8
585
      enabled: 1
586
      index: issn
587
      aliases:
588
        - issn
589
        - ns
590
      label: Issn
591
    issues:
592
      bib1_mapping:
593
        biblioserver:
594
          1: 8019
595
      enabled: 1
596
      index: issues
597
      aliases:
598
        - issues
599
      label: Issues
600
    item:
601
      bib1_mapping:
602
        biblioserver:
603
          1: 9520
604
      enabled: 1
605
      index: item
606
      aliases:
607
        - item
608
      label: Item
609
    itemnumber:
610
      bib1_mapping:
611
        biblioserver:
612
          1: 8010
613
      enabled: 1
614
      index: itemnumber
615
      aliases:
616
        - itemnumber
617
      label: Itemnumber
618
    itemtype:
619
      bib1_mapping:
620
        biblioserver:
621
          1: 9006
622
      enabled: 1
623
      index: itemtype
624
      aliases:
625
        - itemtype
626
        - mc-itemtype
627
      label: Itemtype
628
    itype:
629
      bib1_mapping:
630
        biblioserver:
631
          1: 8031
632
      enabled: 1
633
      index: itype
634
      aliases:
635
        - itype
636
        - mc-itype
637
      label: Itype
638
    l-format:
639
      bib1_mapping:
640
        biblioserver:
641
          1: 8703
642
      enabled: 1
643
      index: l-format
644
      aliases:
645
        - l-format
646
      label: L-format
647
    language:
648
      bib1_mapping:
649
        biblioserver:
650
          1: 54
651
      enabled: 1
652
      index: language
653
      aliases:
654
        - language
655
        - ln
656
      label: Language
657
    lc-card-number:
658
      bib1_mapping:
659
        biblioserver:
660
          1: 9
661
      enabled: 1
662
      index: lc-card-number
663
      aliases:
664
        - lc-card-number
665
        - lc-card
666
      label: Lc-card-number
667
    lex:
668
      bib1_mapping:
669
        biblioserver:
670
          1: 9903 r=r
671
      enabled: 1
672
      index: lex
673
      aliases:
674
        - lex
675
      label: Lex
676
    literature-code:
677
      bib1_mapping:
678
        biblioserver:
679
          1: Literature-Code
680
      enabled: 1
681
      index: literature-code
682
      aliases:
683
        - literature-code
684
      label: Literature-code
685
    llength:
686
      bib1_mapping:
687
        biblioserver:
688
          1: llength
689
      enabled: 1
690
      index: llength
691
      aliases:
692
        - llength
693
      label: Llength
694
    local-classification:
695
      bib1_mapping:
696
        biblioserver:
697
          1: 8022
698
      enabled: 1
699
      index: local-classification
700
      aliases:
701
        - local-classification
702
        - lcn
703
        - callnum
704
      label: Local-classification
705
    local-number:
706
      bib1_mapping:
707
        biblioserver:
708
          1: 12
709
      enabled: 1
710
      index: local-number
711
      aliases:
712
        - local-number
713
        - sn
714
      label: Local-number
715
    location:
716
      bib1_mapping:
717
        biblioserver:
718
          1: 8013
719
      enabled: 1
720
      index: location
721
      aliases:
722
        - location
723
        - mc-loc
724
      label: Location
725
    lost:
726
      bib1_mapping:
727
        biblioserver:
728
          1: 8002
729
      enabled: 1
730
      index: lost
731
      aliases:
732
        - lost
733
      label: Lost
734
    match:
735
      bib1_mapping:
736
        authorityserver:
737
          1: Match
738
      enabled: 1
739
      index: match
740
      aliases:
741
        - match
742
      label: Match
743
    material-type:
744
      bib1_mapping:
745
        biblioserver:
746
          1: Material-type
747
      enabled: 1
748
      index: material-type
749
      aliases:
750
        - material-type
751
      label: Material-type
752
    materials-specified:
753
      bib1_mapping:
754
        biblioserver:
755
          1: 8004
756
      enabled: 1
757
      index: materials-specified
758
      aliases:
759
        - materials-specified
760
      label: Materials-specified
761
    music:
762
      bib1_mapping:
763
        biblioserver:
764
          1: Music-number
765
      enabled: 1
766
      index: music
767
      aliases:
768
        - music
769
      label: Music
770
    name:
771
      bib1_mapping:
772
        biblioserver:
773
          1: 1002
774
      enabled: 1
775
      index: name
776
      aliases:
777
        - name
778
      label: Name
779
    note:
780
      bib1_mapping:
781
        biblioserver:
782
          1: 63
783
      enabled: 1
784
      index: note
785
      aliases:
786
        - note
787
        - nt
788
      label: Note
789
    notforloan:
790
      bib1_mapping:
791
        biblioserver:
792
          1: 8008
793
          4: 109
794
      enabled: 1
795
      index: notforloan
796
      aliases:
797
        - notforloan
798
      label: Notforloan
799
    onloan:
800
      bib1_mapping:
801
        biblioserver:
802
          1: 8024
803
      enabled: 1
804
      index: onloan
805
      aliases:
806
        - onloan
807
      label: Onloan
808
    personal-name:
809
      bib1_mapping:
810
        biblioserver:
811
          1: Personal-name
812
      enabled: 1
813
      index: personal-name
814
      aliases:
815
        - personal-name
816
        - pn
817
      label: Personal-name
818
    place-publication:
819
      bib1_mapping:
820
        biblioserver:
821
          1: 59
822
      enabled: 1
823
      index: place-publication
824
      aliases:
825
        - place-publication
826
        - pl
827
      label: Place-publication
828
    popularity:
829
      bib1_mapping:
830
        biblioserver:
831
          1: issues
832
      enabled: 1
833
      index: popularity
834
      aliases:
835
        - popularity
836
      label: Popularity
837
    price:
838
      bib1_mapping:
839
        biblioserver:
840
          1: 8017
841
      enabled: 1
842
      index: price
843
      aliases:
844
        - price
845
      label: Price
846
    publisher:
847
      bib1_mapping:
848
        biblioserver:
849
          1: 1018
850
      enabled: 1
851
      index: publisher
852
      aliases:
853
        - publisher
854
        - pb
855
      label: Publisher
856
    record-control-number:
857
      bib1_mapping:
858
        biblioserver:
859
          1: 1045
860
      enabled: 1
861
      index: record-control-number
862
      aliases:
863
        - record-control-number
864
        - rcn
865
      label: Record-control-number
866
    record-type:
867
      bib1_mapping:
868
        biblioserver:
869
          1: 1001
870
      enabled: 1
871
      index: record-type
872
      aliases:
873
        - record-type
874
        - rtype
875
        - mc-rtype
876
        - mus
877
      label: Record-type
878
    regularity-code:
879
      bib1_mapping:
880
        biblioserver:
881
          1: Regularity-code
882
      enabled: 1
883
      index: regularity-code
884
      aliases:
885
        - regularity-code
886
      label: Regularity-code
887
    renewals:
888
      bib1_mapping:
889
        biblioserver:
890
          1: 8020
891
      enabled: 1
892
      index: renewals
893
      aliases:
894
        - renewals
895
      label: Renewals
896
    replacementprice:
897
      bib1_mapping:
898
        biblioserver:
899
          1: 8029
900
      enabled: 1
901
      index: replacementprice
902
      aliases:
903
        - replacementprice
904
      label: Replacementprice
905
    replacementpricedate:
906
      bib1_mapping:
907
        biblioserver:
908
          1: 8030
909
      enabled: 1
910
      index: replacementpricedate
911
      aliases:
912
        - replacementpricedate
913
      label: Replacementpricedate
914
    reserves:
915
      bib1_mapping:
916
        biblioserver:
917
          1: 8021
918
      enabled: 1
919
      index: reserves
920
      aliases:
921
        - reserves
922
      label: Reserves
923
    restricted:
924
      bib1_mapping:
925
        biblioserver:
926
          1: 8006
927
      enabled: 1
928
      index: restricted
929
      aliases:
930
        - restricted
931
      label: Restricted
932
    stack:
933
      bib1_mapping:
934
        biblioserver:
935
          1: 8018
936
      enabled: 1
937
      index: stack
938
      aliases:
939
        - stack
940
      label: Stack
941
    stock-number:
942
      bib1_mapping:
943
        biblioserver:
944
          1: 1028
945
      enabled: 1
946
      index: stock-number
947
      aliases:
948
        - stock-number
949
      label: Stock-number
950
    stocknumber:
951
      bib1_mapping:
952
        biblioserver:
953
          1: 1062
954
      enabled: 1
955
      index: stocknumber
956
      aliases:
957
        - stocknumber
958
        - inv
959
      label: Stocknumber
960
    summary:
961
      bib1_mapping:
962
        biblioserver:
963
          1: Summary
964
      enabled: 1
965
      index: summary
966
      aliases:
967
        - summary
968
      label: Summary
969
    suppress:
970
      bib1_mapping:
971
        biblioserver:
972
          1: 9011
973
      enabled: 1
974
      index: suppress
975
      aliases:
976
        - suppress
977
      label: Suppress
978
    titleext:
979
      bib1_mapping:
980
        biblioserver:
981
          1: 4
982
          4: 1
983
          6: 2
984
      enabled: 1
985
      index: title
986
      aliases: []
987
      label: Title ext
988
    titlekw:
989
      bib1_mapping:
990
        biblioserver:
991
          1: 4
992
      enabled: 1
993
      index: title
994
      aliases: []
995
      label: Title kw
996
    thesaurus:
997
      bib1_mapping:
998
        authorityserver:
999
          1: Subject-heading-thesaurus
1000
      enabled: 1
1001
      index: thesaurus
1002
      aliases:
1003
        - thesaurus
1004
      label: Thesaurus
1005
    totalissues:
1006
      bib1_mapping:
1007
        biblioserver:
1008
          1: 9003
1009
      enabled: 1
1010
      index: totalissues
1011
      aliases:
1012
        - totalissues
1013
      label: Totalissues
1014
    type-of-serial:
1015
      bib1_mapping:
1016
        biblioserver:
1017
          1: Type-Of-Serial
1018
      enabled: 1
1019
      index: type-of-serial
1020
      aliases:
1021
        - type-of-serial
1022
      label: Type-of-serial
1023
    upc:
1024
      bib1_mapping:
1025
        biblioserver:
1026
          1: UPC
1027
      enabled: 1
1028
      index: upc
1029
      aliases:
1030
        - upc
1031
      label: Upc
1032
    uri:
1033
      bib1_mapping:
1034
        biblioserver:
1035
          1: 8028
1036
      enabled: 1
1037
      index: uri
1038
      aliases:
1039
        - uri
1040
      label: Uri
1041
    video-mt:
1042
      bib1_mapping:
1043
        biblioserver:
1044
          1: Video-mt
1045
      enabled: 1
1046
      index: video-mt
1047
      aliases:
1048
        - video-mt
1049
      label: Video-mt
1050
    withdrawn:
1051
      bib1_mapping:
1052
        biblioserver:
1053
          1: 8001
1054
      enabled: 1
1055
      index: withdrawn
1056
      aliases:
1057
        - withdrawn
1058
      label: Withdrawn
1059
  subject:
1060
    subject:
1061
      bib1_mapping:
1062
        authorityserver:
1063
          1: Match-heading
1064
        biblioserver:
1065
          1: 21
1066
      enabled: 1
1067
      index: ''
1068
      label: ''
1069
      aliases:
1070
        - su
1071
        - su-to
1072
        - su-geo
1073
        - su-ut
1074
    authority-number:
1075
      bib1_mapping:
1076
        biblioserver:
1077
          1: Koha-Auth-Number
1078
      enabled: 1
1079
      index: authority-number
1080
      label: Authority-number
1081
      aliases:
1082
        - authority-number
1083
        - an
1084
    complete:
1085
      bib1_mapping:
1086
        biblioserver:
1087
          1: 21
1088
          3: 1
1089
          4: 1
1090
          5: 100
1091
          6: 3
1092
      enabled: 1
1093
      index: complete
1094
      label: Complete
1095
      aliases:
1096
        - complete
1097
    exact:
1098
      bib1_mapping:
1099
        authorityserver:
1100
          4: 1
1101
          5: 100
1102
          6: 3
1103
      enabled: 1
1104
      index: exact
1105
      label: Exact
1106
      aliases:
1107
        - exact
1108
    heading:
1109
      bib1_mapping:
1110
        authorityserver:
1111
          1: Heading
1112
      enabled: 1
1113
      index: heading
1114
      label: Heading
1115
      aliases:
1116
        - heading
1117
        - mainentry
1118
        - he
1119
    headingmain:
1120
      bib1_mapping:
1121
        authorityserver:
1122
          1: Heading-Main
1123
      enabled: 1
1124
      index: headingmain
1125
      label: Headingmain
1126
      aliases:
1127
        - headingmain
1128
        - mainmainentry
1129
    matchheading:
1130
      bib1_mapping:
1131
        authorityserver:
1132
          1: Match-heading
1133
      enabled: 1
1134
      index: matchheading
1135
      label: Matchheading
1136
      aliases:
1137
        - matchheading
1138
        - match-heading
1139
    name-personal:
1140
      bib1_mapping:
1141
        biblioserver:
1142
          1: 1009
1143
      enabled: 1
1144
      index: name-personal
1145
      label: Name-personal
1146
      aliases:
1147
        - name-personal
1148
        - su-na
1149
    seefrom:
1150
      bib1_mapping:
1151
        authorityserver:
1152
          1: Match-heading-see-from
1153
      enabled: 1
1154
      index: seefrom
1155
      label: Seefrom
1156
      aliases:
1157
        - seefrom
1158
        - see-from
1159
    start:
1160
      bib1_mapping:
1161
        authorityserver:
1162
          3: 2
1163
          4: 1
1164
          5: 1
1165
      enabled: 1
1166
      index: start
1167
      label: Start
1168
      aliases:
1169
        - start
1170
  title:
1171
    title:
1172
      bib1_mapping:
1173
        biblioserver:
1174
          1: 4
1175
      enabled: 1
1176
      index: ''
1177
      label: ''
1178
      aliases:
1179
        - ti
1180
    cover:
1181
      bib1_mapping:
1182
        biblioserver:
1183
          1: 36
1184
      enabled: 1
1185
      index: cover
1186
      label: Cover
1187
      aliases:
1188
        - cover
1189
        - title-cover
1190
    exacttitle:
1191
      bib1_mapping:
1192
        biblioserver:
1193
          1: 4
1194
          4: 1
1195
          6: 3
1196
      enabled: 1
1197
      index: exacttitle
1198
      label: Exacttitle
1199
      aliases:
1200
        - exacttitle
1201
        - ti,ext
1202
    series:
1203
      bib1_mapping:
1204
        biblioserver:
1205
          1: 5
1206
      enabled: 1
1207
      index: series
1208
      label: Series
1209
      aliases:
1210
        - series
1211
        - title-series
1212
        - se
1213
    uniform:
1214
      bib1_mapping:
1215
        biblioserver:
1216
          1: Title-uniform
1217
      enabled: 1
1218
      index: uniform
1219
      label: Uniform
1220
      aliases:
1221
        - uniform
1222
        - title-uniform
1223
filter_mappings:
1224
  acqdate:
1225
    bib1_mapping:
1226
      biblioserver:
1227
        1: Date-of-acquisition
1228
        4: 4
1229
        target_syntax_callback: date_filter_target_callback
1230
    enabled: 1
1231
    label: Acqdate
1232
  copydate:
1233
    bib1_mapping:
1234
      biblioserver:
1235
        1: 30
1236
        4: 4
1237
        target_syntax_callback: date_filter_target_callback
1238
1239
    enabled: 1
1240
    label: Copydate
1241
  pubdate:
1242
    bib1_mapping:
1243
      biblioserver:
1244
        1: pubdate
1245
        4: 4
1246
        target_syntax_callback: date_filter_target_callback
1247
    enabled: 1
1248
    label: Pubdate
1249
modifier_mappings:
1250
  AuthidAsc:
1251
    bib1_mapping:
1252
      authorityserver:
1253
        "": 0
1254
        1: Local-Number
1255
        7: 1
1256
        op: "@or"
1257
    enabled: 1
1258
    label: AuthidAsc
1259
  AuthidDsc:
1260
    bib1_mapping:
1261
      authorityserver:
1262
        "": 0
1263
        1: Local-Number
1264
        7: 2
1265
        op: "@or"
1266
    enabled: 1
1267
    label: AuthidDsc
1268
  HeadingAsc:
1269
    bib1_mapping:
1270
      authorityserver:
1271
        "": 0
1272
        1: Heading
1273
        7: 1
1274
        op: "@or"
1275
    enabled: 1
1276
    label: HeadingAsc
1277
  HeadingDsc:
1278
    bib1_mapping:
1279
      authorityserver:
1280
        "": 0
1281
        1: Heading
1282
        7: 2
1283
        op: "@or"
1284
    enabled: 1
1285
    label: HeadingDsc
1286
  Relevance:
1287
    bib1_mapping:
1288
      authorityserver:
1289
        2: 102
1290
    enabled: 1
1291
    label: Relevance
1292
  acqdate_asc:
1293
    bib1_mapping:
1294
      biblioserver:
1295
        "": 0
1296
        1: 32
1297
        7: 2
1298
        op: "@or"
1299
    enabled: 1
1300
    label: Acqdate_asc
1301
  acqdate_dsc:
1302
    bib1_mapping:
1303
      biblioserver:
1304
        "": 0
1305
        1: 32
1306
        7: 1
1307
        op: "@or"
1308
    enabled: 1
1309
    label: Acqdate_dsc
1310
  ascending:
1311
    bib1_mapping:
1312
      biblioserver:
1313
        7: 1
1314
    enabled: 1
1315
    label: Ascending
1316
  author_asc:
1317
    bib1_mapping:
1318
      biblioserver:
1319
        "": 0
1320
        1: 1003
1321
        7: 2
1322
        op: "@or"
1323
    enabled: 1
1324
    label: Author_asc
1325
  author_az:
1326
    bib1_mapping:
1327
      biblioserver:
1328
        "": 0
1329
        1: 1003
1330
        7: 1
1331
        op: "@or"
1332
    enabled: 1
1333
    label: Author_az
1334
  author_dsc:
1335
    bib1_mapping:
1336
      biblioserver:
1337
        "": 0
1338
        1: 1003
1339
        7: 1
1340
        op: "@or"
1341
    enabled: 1
1342
    label: Author_dsc
1343
  author_za:
1344
    bib1_mapping:
1345
      biblioserver:
1346
        "": 0
1347
        1: 1003
1348
        7: 2
1349
        op: "@or"
1350
    enabled: 1
1351
    label: Author_za
1352
  call_number_asc:
1353
    bib1_mapping:
1354
      biblioserver:
1355
        "": 0
1356
        1: 8007
1357
        7: 2
1358
        op: "@or"
1359
    enabled: 1
1360
    label: Call_number_asc
1361
  call_number_dsc:
1362
    bib1_mapping:
1363
      biblioserver:
1364
        "": 0
1365
        1: 8007
1366
        7: 1
1367
        op: "@or"
1368
    enabled: 1
1369
    label: Call_number_dsc
1370
  descending:
1371
    bib1_mapping:
1372
      biblioserver:
1373
        7: 2
1374
    enabled: 1
1375
    label: Descending
1376
  popularity_asc:
1377
    bib1_mapping:
1378
      biblioserver:
1379
        "": 0
1380
        1: 9003
1381
        7: 2
1382
        op: "@or"
1383
    enabled: 1
1384
    label: Popularity_asc
1385
  popularity_dsc:
1386
    bib1_mapping:
1387
      biblioserver:
1388
        "": 0
1389
        1: 9003
1390
        7: 1
1391
        op: "@or"
1392
    enabled: 1
1393
    label: Popularity_dsc
1394
  pubdate_asc:
1395
    bib1_mapping:
1396
      biblioserver:
1397
        "": 0
1398
        1: 31
1399
        7: 2
1400
        op: "@or"
1401
    enabled: 1
1402
    label: Pubdate_asc
1403
  pubdate_dsc:
1404
    bib1_mapping:
1405
      biblioserver:
1406
        "": 0
1407
        1: 31
1408
        7: 1
1409
        op: "@or"
1410
    enabled: 1
1411
    label: Pubdate_dsc
1412
  relevance:
1413
    bib1_mapping:
1414
      biblioserver:
1415
        2: 102
1416
    enabled: 1
1417
    label: Relevance
1418
  relevance_dsc:
1419
    bib1_mapping:
1420
      biblioserver:
1421
        2: 102
1422
    enabled: 1
1423
    label: Relevance_dsc
1424
  title-sort-az:
1425
    bib1_mapping:
1426
      biblioserver:
1427
        "": 0
1428
        1: 36
1429
        7: 1
1430
        op: "@or"
1431
    enabled: 1
1432
    label: Title-sort-az
1433
  title-sort-za:
1434
    bib1_mapping:
1435
      biblioserver:
1436
        "": 0
1437
        1: 36
1438
        7: 2
1439
        op: "@or"
1440
    enabled: 1
1441
    label: Title-sort-za
1442
  title_asc:
1443
    bib1_mapping:
1444
      biblioserver:
1445
        "": 0
1446
        1: 4
1447
        7: 1
1448
        op: "@or"
1449
    enabled: 1
1450
    label: Title_asc
1451
  title_az:
1452
    bib1_mapping:
1453
      biblioserver:
1454
        "": 0
1455
        1: 4
1456
        7: 1
1457
        op: "@or"
1458
    enabled: 1
1459
    label: Title_az
1460
  title_dsc:
1461
    bib1_mapping:
1462
      biblioserver:
1463
        "": 0
1464
        1: 4
1465
        7: 2
1466
        op: "@or"
1467
    enabled: 1
1468
    label: Title_dsc
1469
  title_za:
1470
    bib1_mapping:
1471
      biblioserver:
1472
        "": 0
1473
        1: 4
1474
        7: 2
1475
        op: "@or"
1476
    enabled: 1
1477
    label: Title_za
1478
relevance_bumps:
1479
  keyword:
1480
    titleext:
1481
      enabled: 1
1482
      bib1_mapping:
1483
        biblioserver: 34
1484
    titlekw:
1485
      enabled: 1
1486
      bib1_mapping:
1487
        biblioserver: 20
(-)a/t/QueryParser.t (-1 / +95 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
6
use Test::More;
7
use Test::Deep;
8
use Module::Load::Conditional qw(can_load);
9
10
BEGIN {
11
    use_ok( 'Koha::QueryParser::Driver::PQF' );
12
}
13
14
my $QParser = Koha::QueryParser::Driver::PQF->new();
15
16
ok(defined $QParser, 'Successfully created empty QP object');
17
ok($QParser->load_config('./etc/searchengine/queryparser.yaml'), 'Loaded QP config');
18
19
is($QParser->search_class_count, 4, 'Initialized 4 search classes');
20
is (scalar(@{$QParser->search_fields()->{'keyword'}}), 107, "Correct number of search fields for 'keyword' class");
21
22
is($QParser->target_syntax('biblioserver', 'smith'), '@or @or @attr 1=1016 @attr 4=6 "smith" @attr 9=20 @attr 2=102 @attr 4=6 "smith" @attr 9=34 @attr 2=102 @attr 4=6 "smith"', 'super simple keyword query');
23
is($QParser->target_syntax('biblioserver', 'au:smith'), '@attr 1=1003 @attr 4=6 "smith"', 'simple author query');
24
is($QParser->target_syntax('biblioserver', 'keyword|publisher:smith'), '@attr 1=1018 @attr 4=6 "smith"', 'fielded publisher query');
25
is($QParser->target_syntax('biblioserver', 'ti:"little engine that could"'), '@attr 1=4 @attr 4=1 "little engine that could"', 'phrase query');
26
is($QParser->target_syntax('biblioserver', 'keyword|titlekw:smith'), '@attr 1=4 @attr 9=20 @attr 2=102 @attr 4=6 "smith"', 'relevance-bumped query');
27
is($QParser->target_syntax('biblioserver', 'au:smith && johnson'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 1=1003 @attr 4=6 "johnson"', 'query with boolean &&');
28
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(-2008)'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 4=4 @attr 1=pubdate @attr 2=2 "2008"', 'keyword search with pubdate limited to -2008');
29
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(2008-)'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 4=4 @attr 1=pubdate @attr 2=4 "2008"', 'keyword search with pubdate limited to 2008-');
30
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(2008)'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 4=4 @attr 1=pubdate "2008"', 'keyword search with pubdate limited to 2008');
31
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(1980,2008)'), '@and @attr 1=1003 @attr 4=6 "smith" @or @attr 4=4 @attr 1=pubdate "1980" @attr 4=4 @attr 1=pubdate "2008"', 'keyword search with pubdate limited to 1980, 2008');
32
is($QParser->target_syntax('biblioserver', 'au:smith #acqdate_dsc'), '@or @attr 1=32 @attr 7=1 0 @attr 1=1003 @attr 4=6 "smith"', 'keyword search sorted by acqdate descending');
33
is($QParser->bib1_mapping_by_attr('field', 'biblioserver', {'1' => '1004'})->{'field'}, 'personal', 'retrieve field by attr');
34
is($QParser->bib1_mapping_by_attr_string('field', 'biblioserver', '@attr 1=1004')->{'field'}, 'personal', 'retrieve field by attrstring');
35
36
is ($QParser->clear_all_mappings, $QParser, 'clear all mappings returns self');
37
is ($QParser->clear_all_configuration, $QParser, 'clear all configuration returns self');
38
is (scalar(keys(%{$QParser->search_fields})), 0, "All mapping erased");
39
40
$QParser->add_bib1_field_map('author' => 'personal' => 'biblioserver' => { '1' => '1004' } );
41
$QParser->add_bib1_modifier_map('relevance' => 'biblioserver' => { '2' => '102' } );
42
my $desired_config = {
43
  'field_mappings' => {
44
    'author' => {
45
      'personal' => {
46
        'aliases' => [
47
          'personal'
48
        ],
49
        'bib1_mapping' => {
50
          'biblioserver' => {
51
            '1' => '1004'
52
          }
53
        },
54
        'enabled' => '1',
55
        'index' => 'personal',
56
        'label' => 'Personal'
57
      }
58
    }
59
  },
60
  'filter_mappings' => {},
61
  'modifier_mappings' => {
62
    'relevance' => {
63
      'bib1_mapping' => {
64
        'biblioserver' => {
65
          '2' => '102'
66
        }
67
      },
68
      'enabled' => 1,
69
      'label' => 'Relevance'
70
    }
71
  },
72
  'relevance_bumps' => {}
73
};
74
75
SKIP: {
76
    my $got_config;
77
    skip 'YAML is unavailable', 2 unless can_load('modules' => { 'YAML::Any' => undef });
78
    $got_config = YAML::Any::Load($QParser->serialize_mappings());
79
    ok(ref $got_config, 'serialized YAML valid');
80
    is_deeply($got_config, $desired_config, 'Mappings serialized correctly to YAML');
81
82
    skip 'JSON is unavailable', 2 unless can_load('modules' => { 'JSON' => undef });
83
    undef $got_config;
84
    eval {
85
        $got_config = JSON::from_json($QParser->serialize_mappings('json'));
86
    };
87
    is($@, '', 'serialized JSON valid');
88
    is_deeply($got_config, $desired_config, 'Mappings serialized correctly to JSON');
89
}
90
91
$QParser->clear_all_mappings;
92
is($QParser->TEST_SETUP, $QParser, 'TEST_SETUP returns self');
93
is($QParser->search_class_count, 4, 'Initialized 4 search classes in test setup');
94
95
done_testing();

Return to bug 9239