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

(-)a/C4/Search.pm (-90 / +71 lines)
Lines 312-333 sub SimpleSearch { Link Here
312
( undef, $results_hashref, \@facets_loop ) = getRecords (
312
( undef, $results_hashref, \@facets_loop ) = getRecords (
313
313
314
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
314
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
315
        $results_per_page, $offset,       $expanded_facet, $branches,$itemtypes,
315
        $results_per_page, $offset,       $branches,       $itemtypes,
316
        $query_type,       $scan
316
        $query_type,       $scan,         $opac
317
    );
317
    );
318
318
319
The all singing, all dancing, multi-server, asynchronous, scanning,
319
The all singing, all dancing, multi-server, asynchronous, scanning,
320
searching, record nabbing, facet-building
320
searching, record nabbing, facet-building
321
321
322
See verbse embedded documentation.
322
See verbose embedded documentation.
323
323
324
=cut
324
=cut
325
325
326
sub getRecords {
326
sub getRecords {
327
    my (
327
    my (
328
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
328
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
329
        $results_per_page, $offset,       $expanded_facet, $branches,
329
        $results_per_page, $offset,       $branches,         $itemtypes,
330
        $itemtypes,        $query_type,   $scan,           $opac
330
        $query_type,       $scan,         $opac
331
    ) = @_;
331
    ) = @_;
332
332
333
    my @servers = @$servers_ref;
333
    my @servers = @$servers_ref;
Lines 516-523 sub getRecords { Link Here
516
                        keys %$facets_counter
516
                        keys %$facets_counter
517
                      )
517
                      )
518
                    {
518
                    {
519
                        my $expandable;
520
                        my $number_of_facets;
521
                        my @this_facets_array;
519
                        my @this_facets_array;
522
                        for my $one_facet (
520
                        for my $one_facet (
523
                            sort {
521
                            sort {
Lines 527-620 sub getRecords { Link Here
527
                            } keys %{ $facets_counter->{$link_value} }
525
                            } keys %{ $facets_counter->{$link_value} }
528
                          )
526
                          )
529
                        {
527
                        {
530
                            $number_of_facets++;
531
                            if (   ( $number_of_facets <= 5 )
532
                                || ( $expanded_facet eq $link_value )
533
                                || ( $facets_info->{$link_value}->{'expanded'} )
534
                              )
535
                            {
536
537
# Sanitize the link value : parenthesis, question and exclamation mark will cause errors with CCL
528
# Sanitize the link value : parenthesis, question and exclamation mark will cause errors with CCL
538
                                my $facet_link_value = $one_facet;
529
                            my $facet_link_value = $one_facet;
539
                                $facet_link_value =~ s/[()!?¡¿؟]/ /g;
530
                            $facet_link_value =~ s/[()!?¡¿؟]/ /g;
540
531
541
                                # fix the length that will display in the label,
532
                            # fix the length that will display in the label,
542
                                my $facet_label_value = $one_facet;
533
                            my $facet_label_value = $one_facet;
543
                                my $facet_max_length  = C4::Context->preference(
534
                            my $facet_max_length  = C4::Context->preference(
544
                                    'FacetLabelTruncationLength')
535
                                'FacetLabelTruncationLength')
545
                                  || 20;
536
                              || 20;
546
                                $facet_label_value =
537
                            $facet_label_value =
547
                                  substr( $one_facet, 0, $facet_max_length )
538
                              substr( $one_facet, 0, $facet_max_length )
548
                                  . "..."
539
                              . "..."
549
                                  if length($facet_label_value) >
540
                              if length($facet_label_value) >
550
                                      $facet_max_length;
541
                                  $facet_max_length;
551
542
552
                            # if it's a branch, label by the name, not the code,
543
                        # if it's a branch, label by the name, not the code,
553
                                if ( $link_value =~ /branch/ ) {
544
                            if ( $link_value =~ /branch/ ) {
554
                                    if (   defined $branches
545
                                if (   defined $branches
555
                                        && ref($branches) eq "HASH"
546
                                    && ref($branches) eq "HASH"
556
                                        && defined $branches->{$one_facet}
547
                                    && defined $branches->{$one_facet}
557
                                        && ref( $branches->{$one_facet} ) eq
548
                                    && ref( $branches->{$one_facet} ) eq
558
                                        "HASH" )
549
                                    "HASH" )
559
                                    {
550
                                {
560
                                        $facet_label_value =
551
                                    $facet_label_value =
561
                                          $branches->{$one_facet}
552
                                      $branches->{$one_facet}
562
                                          ->{'branchname'};
553
                                      ->{'branchname'};
563
                                    }
564
                                    else {
565
                                        $facet_label_value = "*";
566
                                    }
567
                                }
554
                                }
568
555
                                else {
569
                          # if it's a itemtype, label by the name, not the code,
556
                                    $facet_label_value = "*";
570
                                if ( $link_value =~ /itype/ ) {
571
                                    if (   defined $itemtypes
572
                                        && ref($itemtypes) eq "HASH"
573
                                        && defined $itemtypes->{$one_facet}
574
                                        && ref( $itemtypes->{$one_facet} ) eq
575
                                        "HASH" )
576
                                    {
577
                                        $facet_label_value =
578
                                          $itemtypes->{$one_facet}
579
                                          ->{translated_description};
580
                                    }
581
                                }
557
                                }
558
                            }
582
559
583
               # also, if it's a location code, use the name instead of the code
560
                      # if it's a itemtype, label by the name, not the code,
584
                                if ( $link_value =~ /location/ ) {
561
                            if ( $link_value =~ /itype/ ) {
585
                                    # TODO Retrieve all authorised values at once, instead of 1 query per entry
562
                                if (   defined $itemtypes
586
                                    my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet });
563
                                    && ref($itemtypes) eq "HASH"
587
                                    $facet_label_value = $av->count ? $av->next->opac_description : '';
564
                                    && defined $itemtypes->{$one_facet}
565
                                    && ref( $itemtypes->{$one_facet} ) eq
566
                                    "HASH" )
567
                                {
568
                                    $facet_label_value =
569
                                      $itemtypes->{$one_facet}
570
                                      ->{translated_description};
588
                                }
571
                                }
572
                            }
589
573
590
                                # also, if it's a collection code, use the name instead of the code
574
           # also, if it's a location code, use the name instead of the code
591
                                if ( $link_value =~ /ccode/ ) {
575
                            if ( $link_value =~ /location/ ) {
592
                                    # TODO Retrieve all authorised values at once, instead of 1 query per entry
576
                                # TODO Retrieve all authorised values at once, instead of 1 query per entry
593
                                    my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $one_facet });
577
                                my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet });
594
                                    $facet_label_value = $av->count ? $av->next->opac_description : '';
578
                                $facet_label_value = $av->count ? $av->next->opac_description : '';
595
                                }
579
                            }
596
580
597
                # but we're down with the whole label being in the link's title.
581
                            # also, if it's a collection code, use the name instead of the code
598
                                push @this_facets_array,
582
                            if ( $link_value =~ /ccode/ ) {
599
                                  {
583
                                # TODO Retrieve all authorised values at once, instead of 1 query per entry
600
                                    facet_count =>
584
                                my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $one_facet });
601
                                      $facets_counter->{$link_value}
585
                                $facet_label_value = $av->count ? $av->next->opac_description : '';
602
                                      ->{$one_facet},
603
                                    facet_label_value => $facet_label_value,
604
                                    facet_title_value => $one_facet,
605
                                    facet_link_value  => $facet_link_value,
606
                                    type_link_value   => $link_value,
607
                                  }
608
                                  if ($facet_label_value);
609
                            }
586
                            }
610
                        }
611
587
612
                        # handle expanded option
588
            # but we're down with the whole label being in the link's title.
613
                        unless ( $facets_info->{$link_value}->{'expanded'} ) {
589
                            push @this_facets_array,
614
                            $expandable = 1
590
                              {
615
                              if ( ( $number_of_facets > 5 )
591
                                facet_count =>
616
                                && ( $expanded_facet ne $link_value ) );
592
                                  $facets_counter->{$link_value}
593
                                  ->{$one_facet},
594
                                facet_label_value => $facet_label_value,
595
                                facet_title_value => $one_facet,
596
                                facet_link_value  => $facet_link_value,
597
                                type_link_value   => $link_value,
598
                              }
599
                              if ($facet_label_value);
617
                        }
600
                        }
601
618
                        push @facets_loop,
602
                        push @facets_loop,
619
                          {
603
                          {
620
                            type_link_value => $link_value,
604
                            type_link_value => $link_value,
Lines 623-630 sub getRecords { Link Here
623
                              . $facets_info->{$link_value}->{'label_value'} =>
607
                              . $facets_info->{$link_value}->{'label_value'} =>
624
                              1,
608
                              1,
625
                            facets     => \@this_facets_array,
609
                            facets     => \@this_facets_array,
626
                            expandable => $expandable,
627
                            expand     => $link_value,
628
                          }
610
                          }
629
                          unless (
611
                          unless (
630
                            (
612
                            (
Lines 852-858 sub _get_facets_info { Link Here
852
834
853
    for my $facet ( @$facets ) {
835
    for my $facet ( @$facets ) {
854
        $facets_info->{ $facet->{ idx } }->{ label_value } = $facet->{ label };
836
        $facets_info->{ $facet->{ idx } }->{ label_value } = $facet->{ label };
855
        $facets_info->{ $facet->{ idx } }->{ expanded }    = $facet->{ expanded };
856
    }
837
    }
857
838
858
    return $facets_info;
839
    return $facets_info;
Lines 861-868 sub _get_facets_info { Link Here
861
sub pazGetRecords {
842
sub pazGetRecords {
862
    my (
843
    my (
863
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
844
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
864
        $results_per_page, $offset,       $expanded_facet, $branches,
845
        $results_per_page, $offset,       $branches,       $query_type,
865
        $query_type,       $scan
846
        $scan
866
    ) = @_;
847
    ) = @_;
867
    #NOTE: Parameter $branches is not used here !
848
    #NOTE: Parameter $branches is not used here !
868
849
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-12 / +9 lines)
Lines 111-125 sub build_query { Link Here
111
111
112
    # See _convert_facets in Search.pm for how these get turned into
112
    # See _convert_facets in Search.pm for how these get turned into
113
    # things that Koha can use.
113
    # things that Koha can use.
114
    my $size = C4::Context->preference('FacetMaxCount');
114
    $res->{aggregations} = {
115
    $res->{aggregations} = {
115
        author         => { terms => { field => "author__facet" } },
116
        author         => { terms => { field => "author__facet" , size => $size } },
116
        subject        => { terms => { field => "subject__facet" } },
117
        subject        => { terms => { field => "subject__facet", size => $size } },
117
        itype          => { terms => { field => "itype__facet" } },
118
        itype          => { terms => { field => "itype__facet", size => $size} },
118
        location       => { terms => { field => "location__facet" } },
119
        location       => { terms => { field => "location__facet", size => $size } },
119
        'su-geo'       => { terms => { field => "su-geo__facet" } },
120
        'su-geo'       => { terms => { field => "su-geo__facet", size => $size} },
120
        'title-series' => { terms => { field => "title-series__facet" } },
121
        'title-series' => { terms => { field => "title-series__facet", size => $size } },
121
        ccode          => { terms => { field => "ccode__facet" } },
122
        ccode          => { terms => { field => "ccode__facet", size => $size } },
122
        ln             => { terms => { field => "ln__facet" } },
123
        ln             => { terms => { field => "ln__facet", size => $size } },
123
    };
124
    };
124
125
125
    my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
126
    my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
Lines 131-139 sub build_query { Link Here
131
        or $display_library_facets eq 'holding' ) {
132
        or $display_library_facets eq 'holding' ) {
132
        $res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet" } };
133
        $res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet" } };
133
    }
134
    }
134
    if ( my $ef = $options{expanded_facet} ) {
135
        $res->{aggregations}{$ef}{terms}{size} = C4::Context->preference('FacetMaxCount');
136
    };
137
    return $res;
135
    return $res;
138
}
136
}
139
137
Lines 243-249 sub build_query_compat { Link Here
243
    my %options;
241
    my %options;
244
    $options{fields} = \@fields;
242
    $options{fields} = \@fields;
245
    $options{sort} = \@sort_params;
243
    $options{sort} = \@sort_params;
246
    $options{expanded_facet} = $params->{expanded_facet};
247
    my $query = $self->build_query( $query_str, %options );
244
    my $query = $self->build_query( $query_str, %options );
248
245
249
    # We roughly emulate the CGI parameters of the zebra query builder
246
    # We roughly emulate the CGI parameters of the zebra query builder
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-14 / +7 lines)
Lines 132-139 sub count { Link Here
132
132
133
    my ( $error, $results, $facets ) = $search->search_compat(
133
    my ( $error, $results, $facets ) = $search->search_compat(
134
        $query,            $simple_query, \@sort_by,       \@servers,
134
        $query,            $simple_query, \@sort_by,       \@servers,
135
        $results_per_page, $offset,       $expanded_facet, $branches,
135
        $results_per_page, $offset,       $branches,       $query_type,
136
        $query_type,       $scan
136
        $scan
137
      )
137
      )
138
138
139
A search interface somewhat compatible with L<C4::Search->getRecords>. Anything
139
A search interface somewhat compatible with L<C4::Search->getRecords>. Anything
Lines 145-159 get ignored here, along with some other things (like C<@servers>.) Link Here
145
sub search_compat {
145
sub search_compat {
146
    my (
146
    my (
147
        $self,     $query,            $simple_query, $sort_by,
147
        $self,     $query,            $simple_query, $sort_by,
148
        $servers,  $results_per_page, $offset,       $expanded_facet,
148
        $servers,  $results_per_page, $offset,       $branches,
149
        $branches, $query_type,       $scan
149
        $query_type,       $scan
150
    ) = @_;
150
    ) = @_;
151
    my %options;
151
    my %options;
152
    if ( !defined $offset or $offset < 0 ) {
152
    if ( !defined $offset or $offset < 0 ) {
153
        $offset = 0;
153
        $offset = 0;
154
    }
154
    }
155
    $options{offset} = $offset;
155
    $options{offset} = $offset;
156
    $options{expanded_facet} = $expanded_facet;
157
    my $results = $self->search($query, undef, $results_per_page, %options);
156
    my $results = $self->search($query, undef, $results_per_page, %options);
158
157
159
    # Convert each result into a MARC::Record
158
    # Convert each result into a MARC::Record
Lines 171-177 sub search_compat { Link Here
171
    my %result;
170
    my %result;
172
    $result{biblioserver}{hits} = $hits->{'total'};
171
    $result{biblioserver}{hits} = $hits->{'total'};
173
    $result{biblioserver}{RECORDS} = \@records;
172
    $result{biblioserver}{RECORDS} = \@records;
174
    return (undef, \%result, $self->_convert_facets($results->{aggregations}, $expanded_facet));
173
    return (undef, \%result, $self->_convert_facets($results->{aggregations}));
175
}
174
}
176
175
177
=head2 search_auth_compat
176
=head2 search_auth_compat
Lines 418-432 sub max_result_window { Link Here
418
417
419
=head2 _convert_facets
418
=head2 _convert_facets
420
419
421
    my $koha_facets = _convert_facets($es_facets, $expanded_facet);
420
    my $koha_facets = _convert_facets($es_facets);
422
421
423
Converts elasticsearch facets types to the form that Koha expects.
422
Converts elasticsearch facets types to the form that Koha expects.
424
It expects the ES facet name to match the Koha type, for example C<itype>,
423
It expects the ES facet name to match the Koha type, for example C<itype>,
425
C<au>, C<su-to>, etc.
424
C<au>, C<su-to>, etc.
426
425
427
C<$expanded_facet> is the facet that we want to show FacetMaxCount entries for, rather
428
than just 5 like normal.
429
430
=cut
426
=cut
431
427
432
sub _convert_facets {
428
sub _convert_facets {
Lines 476-487 sub _convert_facets { Link Here
476
        next if !exists( $type_to_label{$type} );
472
        next if !exists( $type_to_label{$type} );
477
473
478
        # We restrict to the most popular $limit !results
474
        # We restrict to the most popular $limit !results
479
        my $limit = ( $type eq $exp_facet ) ? C4::Context->preference('FacetMaxCount') : 5;
475
        my $limit = C4::Context->preference('FacetMaxCount');
480
        my $facet = {
476
        my $facet = {
481
            type_id    => $type . '_id',
477
            type_id    => $type . '_id',
482
            expand     => $type,
483
            expandable => ( $type ne $exp_facet )
484
              && ( @{ $data->{buckets} } > $limit ),
485
            "type_label_$type_to_label{$type}{label}" => 1,
478
            "type_label_$type_to_label{$type}{label}" => 1,
486
            type_link_value                    => $type,
479
            type_link_value                    => $type,
487
            order      => $type_to_label{$type}{order},
480
            order      => $type_to_label{$type}{order},
(-)a/catalogue/search.pl (-3 / +2 lines)
Lines 459-465 my $offset = $params->{'offset'} || 0; Link Here
459
$offset = 0 if $offset < 0;
459
$offset = 0 if $offset < 0;
460
my $page = $cgi->param('page') || 1;
460
my $page = $cgi->param('page') || 1;
461
#my $offset = ($page-1)*$results_per_page;
461
#my $offset = ($page-1)*$results_per_page;
462
my $expanded_facet = $params->{'expand'};
463
462
464
# Define some global variables
463
# Define some global variables
465
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
464
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
Lines 536-543 eval { Link Here
536
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
535
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
537
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
536
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
538
        $query,            $simple_query, \@sort_by,       \@servers,
537
        $query,            $simple_query, \@sort_by,       \@servers,
539
        $results_per_page, $offset,       $expanded_facet, undef,
538
        $results_per_page, $offset,       undef,           $itemtypes,
540
        $itemtypes,        $query_type,   $scan
539
        $query_type,       $scan
541
    );
540
    );
542
};
541
};
543
542
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc (-3 / +10 lines)
Lines 33-39 Link Here
33
  [% FOREACH facet IN facets_loo.facets %]
33
  [% FOREACH facet IN facets_loo.facets %]
34
  [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,0) || facet.facet_label_value %][% END %]
34
  [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,0) || facet.facet_label_value %][% END %]
35
  [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
35
  [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
36
  [% IF loop.count > 5 && !facet.active %]
37
    <li class="collapsible-facet" style="display:none">
38
  [% ELSE %]
36
    <li>
39
    <li>
40
  [% END %]
37
      [% IF facet.active %]
41
      [% IF facet.active %]
38
        [% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _  facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
42
        [% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _  facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
39
        <span class="facet-label">[% facet.facet_label_value | html %]</span>
43
        <span class="facet-label">[% facet.facet_label_value | html %]</span>
Lines 47-55 Link Here
47
      [% END %]
51
      [% END %]
48
    </li>
52
    </li>
49
  [% END %]
53
  [% END %]
50
  [% IF ( facets_loo.expandable ) %]
54
  [% IF facets_loo.facets.size > 5 %]
51
      <li class="showmore">
55
      <li class="moretoggle">
52
          <a href="[% url | $raw %][% IF offset %]&amp;offset=[% offset | uri %][% END %]&amp;expand=[% facets_loo.expand | uri %]#[% facets_loo.type_id | uri %]">Show more</a>
56
          Show more
57
      </li>
58
      <li class="moretoggle" style="display:none">
59
          Show less
53
      </li>
60
      </li>
54
  [% END %]
61
  [% END %]
55
</ul></li>
62
</ul></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (+7 lines)
Lines 667-672 Link Here
667
        [% END %]
667
        [% END %]
668
        var Sticky;
668
        var Sticky;
669
        $(document).ready(function() {
669
        $(document).ready(function() {
670
671
            $(".moretoggle").click(function() {
672
                $(this).siblings(".collapsible-facet").toggle();
673
                $(this).siblings(".moretoggle").toggle();
674
                $(this).toggle();
675
            });
676
670
            Sticky = $("#searchheader");
677
            Sticky = $("#searchheader");
671
            Sticky.hcSticky({
678
            Sticky.hcSticky({
672
                stickTo: "main",
679
                stickTo: "main",
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc (-3 / +10 lines)
Lines 42-48 Link Here
42
                            [% FOREACH facet IN facets_loo.facets %]
42
                            [% FOREACH facet IN facets_loo.facets %]
43
                            [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,1) || facet.facet_label_value %][% END %]
43
                            [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,1) || facet.facet_label_value %][% END %]
44
                            [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
44
                            [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
45
                            [% IF loop.count > 5 && !facet.active %]
46
                                <li class="collapsible-facet" style="display:none">
47
                            [% ELSE %]
45
                                <li>
48
                                <li>
49
                            [% END %]
46
                                  [% IF facet.active %]
50
                                  [% IF facet.active %]
47
                                    [% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _  facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
51
                                    [% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _  facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
48
                                    <span class="facet-label">[% facet.facet_label_value | html %]</span>
52
                                    <span class="facet-label">[% facet.facet_label_value | html %]</span>
Lines 56-64 Link Here
56
                                  [% END %]
60
                                  [% END %]
57
                                </li>
61
                                </li>
58
                            [% END %]
62
                            [% END %]
59
                            [% IF ( facets_loo.expandable ) %]
63
                            [% IF facets_loo.facets.size > 5 %]
60
                                <li class="showmore">
64
                                <li class="moretoggle">
61
                                    <a href="[% url | $raw %][% IF offset %]&amp;offset=[% offset | uri %][% END %]&amp;expand=[% facets_loo.expand | uri %]#[% facets_loo.type_id | uri %]">Show more</a>
65
                                    Show more
66
                                </li>
67
                                <li class="moretoggle" style="display:none">
68
                                    Show less
62
                                </li>
69
                                </li>
63
                            [% END %]
70
                            [% END %]
64
                        </ul>
71
                        </ul>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (+7 lines)
Lines 740-745 function highlightOn() { Link Here
740
}
740
}
741
[% END %]
741
[% END %]
742
$(document).ready(function(){
742
$(document).ready(function(){
743
744
    $(".moretoggle").click(function(){
745
        $(this).siblings(".collapsible-facet").toggle();
746
        $(this).siblings(".moretoggle").toggle();
747
        $(this).toggle();
748
    });
749
743
    [% IF ( OpacHighlightedWords ) %]
750
    [% IF ( OpacHighlightedWords ) %]
744
        $('a.title').each(function() {
751
        $('a.title').each(function() {
745
            $(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc | uri %]");
752
            $(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc | uri %]");
(-)a/opac/opac-detail.pl (-2 / +1 lines)
Lines 224-230 if ($session->param('busc')) { Link Here
224
    {
224
    {
225
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
225
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
226
226
227
        my $expanded_facet = $arrParamsBusc->{'expand'};
228
        my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
227
        my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
229
        my @servers;
228
        my @servers;
230
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
229
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
Lines 236-242 if ($session->param('busc')) { Link Here
236
        $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
235
        $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
237
        my ($error, $results_hashref, $facets);
236
        my ($error, $results_hashref, $facets);
238
        eval {
237
        eval {
239
            ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
238
            ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
240
        };
239
        };
241
        my $hits;
240
        my $hits;
242
        my @newresults;
241
        my @newresults;
(-)a/opac/opac-search.pl (-4 / +2 lines)
Lines 532-538 $offset = 0 if $offset < 0; Link Here
532
my $page = $cgi->param('page') || 1;
532
my $page = $cgi->param('page') || 1;
533
$offset = ($page-1)*$results_per_page if $page>1;
533
$offset = ($page-1)*$results_per_page if $page>1;
534
my $hits;
534
my $hits;
535
my $expanded_facet = $params->{'expand'};
536
535
537
# Define some global variables
536
# Define some global variables
538
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
537
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
Lines 553-559 if (C4::Context->preference('OpacSuppression')) { Link Here
553
}
552
}
554
553
555
my $build_params = {
554
my $build_params = {
556
    expanded_facet => $expanded_facet,
557
    suppress => $suppress
555
    suppress => $suppress
558
};
556
};
559
557
Lines 619-625 if ($tag) { Link Here
619
    # FIXME: No facets for tags search.
617
    # FIXME: No facets for tags search.
620
} elsif ($build_grouped_results) {
618
} elsif ($build_grouped_results) {
621
    eval {
619
    eval {
622
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$query_type,$scan);
620
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$query_type,$scan);
623
    };
621
    };
624
} else {
622
} else {
625
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
623
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
Lines 628-634 if ($tag) { Link Here
628
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
626
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
629
    my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
627
    my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
630
    eval {
628
    eval {
631
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes_nocategory,$query_type,$scan,1);
629
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
632
};
630
};
633
}
631
}
634
632
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-1 / +6 lines)
Lines 169-175 subtest 'build_authorities_query_compat() tests' => sub { Link Here
169
};
169
};
170
170
171
subtest 'build_query tests' => sub {
171
subtest 'build_query tests' => sub {
172
    plan tests => 33;
172
    plan tests => 35;
173
173
174
    my $qb;
174
    my $qb;
175
175
Lines 196-201 subtest 'build_query tests' => sub { Link Here
196
        "sort parameter properly formed"
196
        "sort parameter properly formed"
197
    );
197
    );
198
198
199
    t::lib::Mocks::mock_preference('FacetMaxCount','37');
200
    $query = $qb->build_query('test', %options);
201
    ok( defined $query->{aggregations}{ccode}{terms}{size},'we need to ask for a size or we get only 5 facet' );
202
    is( $query->{aggregations}{ccode}{terms}{size}, 37,'we ask for the size as defined by the syspref FacetMaxCount');
203
199
    t::lib::Mocks::mock_preference('DisplayLibraryFacets','both');
204
    t::lib::Mocks::mock_preference('DisplayLibraryFacets','both');
200
    $query = $qb->build_query();
205
    $query = $qb->build_query();
201
    ok( defined $query->{aggregations}{homebranch},
206
    ok( defined $query->{aggregations}{homebranch},
(-)a/t/db_dependent/Search.t (-76 / +58 lines)
Lines 347-358 sub run_marc21_search_tests { Link Here
347
    my $results_hashref;
347
    my $results_hashref;
348
    my $facets_loop;
348
    my $facets_loop;
349
    ( undef, $results_hashref, $facets_loop ) =
349
    ( undef, $results_hashref, $facets_loop ) =
350
        getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
350
        getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'ccl', undef);
351
    is($results_hashref->{biblioserver}->{hits}, 101, "getRecords keyword search for 'book' matched right number of records");
351
    is($results_hashref->{biblioserver}->{hits}, 101, "getRecords keyword search for 'book' matched right number of records");
352
    is(scalar @{$results_hashref->{biblioserver}->{RECORDS}}, 19, "getRecords returned requested number of records");
352
    is(scalar @{$results_hashref->{biblioserver}->{RECORDS}}, 19, "getRecords returned requested number of records");
353
    my $record5 = $results_hashref->{biblioserver}->{RECORDS}->[5];
353
    my $record5 = $results_hashref->{biblioserver}->{RECORDS}->[5];
354
    ( undef, $results_hashref, $facets_loop ) =
354
    ( undef, $results_hashref, $facets_loop ) =
355
        getRecords('kw:book', 'book', [], [ 'biblioserver' ], '20', 5, undef, \%branches, \%itemtypes, 'ccl', undef);
355
        getRecords('kw:book', 'book', [], [ 'biblioserver' ], '20', 5, \%branches, \%itemtypes, 'ccl', undef);
356
    ok(!defined $results_hashref->{biblioserver}->{RECORDS}->[0] &&
356
    ok(!defined $results_hashref->{biblioserver}->{RECORDS}->[0] &&
357
        !defined $results_hashref->{biblioserver}->{RECORDS}->[1] &&
357
        !defined $results_hashref->{biblioserver}->{RECORDS}->[1] &&
358
        !defined $results_hashref->{biblioserver}->{RECORDS}->[2] &&
358
        !defined $results_hashref->{biblioserver}->{RECORDS}->[2] &&
Lines 361-410 sub run_marc21_search_tests { Link Here
361
        $results_hashref->{biblioserver}->{RECORDS}->[5] eq $record5, "getRecords cursor works");
361
        $results_hashref->{biblioserver}->{RECORDS}->[5] eq $record5, "getRecords cursor works");
362
362
363
    ( undef, $results_hashref, $facets_loop ) =
363
    ( undef, $results_hashref, $facets_loop ) =
364
        getRecords('ti:book', 'ti:book', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
364
        getRecords('ti:book', 'ti:book', [], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef);
365
    is($results_hashref->{biblioserver}->{hits}, 11, "getRecords title search for 'book' matched right number of records");
365
    is($results_hashref->{biblioserver}->{hits}, 11, "getRecords title search for 'book' matched right number of records");
366
366
367
    ( undef, $results_hashref, $facets_loop ) =
367
    ( undef, $results_hashref, $facets_loop ) =
368
        getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
368
        getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef);
369
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords title search for 'Australia' matched right number of records");
369
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords title search for 'Australia' matched right number of records");
370
370
371
( undef, $results_hashref, $facets_loop ) =
371
( undef, $results_hashref, $facets_loop ) =
372
    getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
372
    getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'ccl', undef);
373
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Efectos del ambiente/ &&
373
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Efectos del ambiente/ &&
374
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' &&
374
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' &&
375
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
375
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
376
    , "Simple relevance sorting in getRecords matches old behavior");
376
    , "Simple relevance sorting in getRecords matches old behavior");
377
377
378
( undef, $results_hashref, $facets_loop ) =
378
( undef, $results_hashref, $facets_loop ) =
379
    getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
379
    getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef);
380
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ &&
380
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ &&
381
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[6],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
381
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[6],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
382
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'World health statistics 2009^ien'
382
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'World health statistics 2009^ien'
383
    , "Simple ascending author sorting in getRecords matches old behavior");
383
    , "Simple ascending author sorting in getRecords matches old behavior");
384
384
385
( undef, $results_hashref, $facets_loop ) =
385
( undef, $results_hashref, $facets_loop ) =
386
    getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
386
    getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef);
387
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
387
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
388
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[12],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
388
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[12],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
389
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/
389
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/
390
    , "Simple descending author sorting in getRecords matches old behavior");
390
    , "Simple descending author sorting in getRecords matches old behavior");
391
391
392
( undef, $results_hashref, $facets_loop ) =
392
( undef, $results_hashref, $facets_loop ) =
393
    getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
393
    getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef);
394
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' &&
394
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' &&
395
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ &&
395
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ &&
396
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
396
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
397
    , "Simple ascending publication date sorting in getRecords matches old behavior");
397
    , "Simple ascending publication date sorting in getRecords matches old behavior");
398
398
399
( undef, $results_hashref, $facets_loop ) =
399
( undef, $results_hashref, $facets_loop ) =
400
    getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
400
    getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef);
401
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Estado de salud/ &&
401
ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Estado de salud/ &&
402
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
402
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
403
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies'
403
    MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies'
404
    , "Simple descending publication date sorting in getRecords matches old behavior");
404
    , "Simple descending publication date sorting in getRecords matches old behavior");
405
405
406
    ( undef, $results_hashref, $facets_loop ) =
406
    ( undef, $results_hashref, $facets_loop ) =
407
        getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1);
407
        getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, undef, 1);
408
    $record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]);
408
    $record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]);
409
    is($record->title_proper(), 'Books', "Scan returned requested item");
409
    is($record->title_proper(), 'Books', "Scan returned requested item");
410
    is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term");
410
    is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term");
Lines 418-424 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
418
    $query_type ) = buildQuery([], [ 'salud' ], [], [], [], 0, 'en');
418
    $query_type ) = buildQuery([], [ 'salud' ], [], [], [], 0, 'en');
419
    like($query, qr/kw\W.*salud/, "Built CCL keyword query");
419
    like($query, qr/kw\W.*salud/, "Built CCL keyword query");
420
420
421
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
421
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
422
    is($results_hashref->{biblioserver}->{hits}, 19, "getRecords generated keyword search for 'salud' matched right number of records");
422
    is($results_hashref->{biblioserver}->{hits}, 19, "getRecords generated keyword search for 'salud' matched right number of records");
423
423
424
    my @newresults = searchResults({'interface' => 'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 18, 0, 0,
424
    my @newresults = searchResults({'interface' => 'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 18, 0, 0,
Lines 430-436 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
430
    $query_type ) = buildQuery([ 'and' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
430
    $query_type ) = buildQuery([ 'and' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
431
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed explicit-and CCL keyword query");
431
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed explicit-and CCL keyword query");
432
432
433
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
433
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
434
    is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' explicit-and 'higiene' matched right number of records");
434
    is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' explicit-and 'higiene' matched right number of records");
435
435
436
    ( $error, $query, $simple_query, $query_cgi,
436
    ( $error, $query, $simple_query, $query_cgi,
Lines 438-444 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
438
    $query_type ) = buildQuery([ 'or' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
438
    $query_type ) = buildQuery([ 'or' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
439
    like($query, qr/kw\W.*salud\W.*or.*kw\W.*higiene/, "Built composed explicit-or CCL keyword query");
439
    like($query, qr/kw\W.*salud\W.*or.*kw\W.*higiene/, "Built composed explicit-or CCL keyword query");
440
440
441
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
441
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
442
    is($results_hashref->{biblioserver}->{hits}, 20, "getRecords generated composed keyword search for 'salud' explicit-or 'higiene' matched right number of records");
442
    is($results_hashref->{biblioserver}->{hits}, 20, "getRecords generated composed keyword search for 'salud' explicit-or 'higiene' matched right number of records");
443
443
444
    ( $error, $query, $simple_query, $query_cgi,
444
    ( $error, $query, $simple_query, $query_cgi,
Lines 446-452 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
446
    $query_type ) = buildQuery([], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
446
    $query_type ) = buildQuery([], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
447
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed implicit-and CCL keyword query");
447
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed implicit-and CCL keyword query");
448
448
449
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
449
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
450
    is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' implicit-and 'higiene' matched right number of records");
450
    is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' implicit-and 'higiene' matched right number of records");
451
451
452
    ( $error, $query, $simple_query, $query_cgi,
452
    ( $error, $query, $simple_query, $query_cgi,
Lines 455-461 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
455
    like($query, qr/kw\W.*salud\W*and\W*su-to\W.*Laboratorios/, "Faceted query generated correctly");
455
    like($query, qr/kw\W.*salud\W*and\W*su-to\W.*Laboratorios/, "Faceted query generated correctly");
456
    unlike($query_desc, qr/Laboratorios/, "Facets not included in query description");
456
    unlike($query_desc, qr/Laboratorios/, "Facets not included in query description");
457
457
458
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
458
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
459
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated faceted search matched right number of records");
459
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated faceted search matched right number of records");
460
460
461
461
Lines 463-469 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
463
    $query_desc, $limit, $limit_cgi, $limit_desc,
463
    $query_desc, $limit, $limit_cgi, $limit_desc,
464
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-itype:MP', 'mc-itype:MU' ], [], 0, 'en');
464
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-itype:MP', 'mc-itype:MU' ], [], 0, 'en');
465
465
466
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
466
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
467
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated mc-faceted search matched right number of records");
467
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated mc-faceted search matched right number of records");
468
468
469
469
Lines 471-483 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
471
    $query_desc, $limit, $limit_cgi, $limit_desc,
471
    $query_desc, $limit, $limit_cgi, $limit_desc,
472
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-loc:GEN', 'branch:FFL' ], [], 0, 'en');
472
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-loc:GEN', 'branch:FFL' ], [], 0, 'en');
473
473
474
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
474
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
475
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-faceted search matched right number of records");
475
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-faceted search matched right number of records");
476
476
477
    ( $error, $query, $simple_query, $query_cgi,
477
    ( $error, $query, $simple_query, $query_cgi,
478
    $query_desc, $limit, $limit_cgi, $limit_desc,
478
    $query_desc, $limit, $limit_cgi, $limit_desc,
479
    $query_type ) = buildQuery([], [ 'NEKLS' ], [ 'Code-institution' ], [], [], 0, 'en');
479
    $query_type ) = buildQuery([], [ 'NEKLS' ], [ 'Code-institution' ], [], [], 0, 'en');
480
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
480
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
481
    is($results_hashref->{biblioserver}->{hits}, 12,
481
    is($results_hashref->{biblioserver}->{hits}, 12,
482
       'search using index whose name contains "ns" returns expected results (bug 10271)');
482
       'search using index whose name contains "ns" returns expected results (bug 10271)');
483
483
Lines 485-496 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
485
    ( $error, $query, $simple_query, $query_cgi,
485
    ( $error, $query, $simple_query, $query_cgi,
486
    $query_desc, $limit, $limit_cgi, $limit_desc,
486
    $query_desc, $limit, $limit_cgi, $limit_desc,
487
    $query_type ) = buildQuery([], [ 'book' ], [ 'kw' ], [], [], 0, 'en');
487
    $query_type ) = buildQuery([], [ 'book' ], [ 'kw' ], [], [], 0, 'en');
488
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
488
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
489
    is($results_hashref->{biblioserver}->{hits}, 101, "Search for 'book' with index set to 'kw' returns 101 hits");
489
    is($results_hashref->{biblioserver}->{hits}, 101, "Search for 'book' with index set to 'kw' returns 101 hits");
490
    ( $error, $query, $simple_query, $query_cgi,
490
    ( $error, $query, $simple_query, $query_cgi,
491
    $query_desc, $limit, $limit_cgi, $limit_desc,
491
    $query_desc, $limit, $limit_cgi, $limit_desc,
492
    $query_type ) = buildQuery([ 'and' ], [ 'book', 'another' ], [ 'kw', 'kw' ], [], [], 0, 'en');
492
    $query_type ) = buildQuery([ 'and' ], [ 'book', 'another' ], [ 'kw', 'kw' ], [], [], 0, 'en');
493
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
493
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
494
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'kw:book && kw:another' returns 1 hit");
494
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'kw:book && kw:another' returns 1 hit");
495
    $UseQueryParser = 0;
495
    $UseQueryParser = 0;
496
496
Lines 500-506 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
500
    $query_desc, $limit, $limit_cgi, $limit_desc,
500
    $query_desc, $limit, $limit_cgi, $limit_desc,
501
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'available' ], [], 0, 'en');
501
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'available' ], [], 0, 'en');
502
502
503
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
503
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
504
    is($results_hashref->{biblioserver}->{hits}, 26, "getRecords generated availability-limited search matched right number of records");
504
    is($results_hashref->{biblioserver}->{hits}, 26, "getRecords generated availability-limited search matched right number of records");
505
505
506
    @newresults = searchResults({'interface'=>'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
506
    @newresults = searchResults({'interface'=>'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
Lines 516-543 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
516
    $query_desc, $limit, $limit_cgi, $limit_desc,
516
    $query_desc, $limit, $limit_cgi, $limit_desc,
517
    $query_type ) = buildQuery([], [ 'pqf=@attr 1=_ALLRECORDS @attr 2=103 ""' ], [], [], [], 0, 'en');
517
    $query_type ) = buildQuery([], [ 'pqf=@attr 1=_ALLRECORDS @attr 2=103 ""' ], [], [], [], 0, 'en');
518
518
519
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
519
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
520
    is($results_hashref->{biblioserver}->{hits}, 180, "getRecords on _ALLRECORDS PQF returned all records");
520
    is($results_hashref->{biblioserver}->{hits}, 180, "getRecords on _ALLRECORDS PQF returned all records");
521
521
522
    ( $error, $query, $simple_query, $query_cgi,
522
    ( $error, $query, $simple_query, $query_cgi,
523
    $query_desc, $limit, $limit_cgi, $limit_desc,
523
    $query_desc, $limit, $limit_cgi, $limit_desc,
524
    $query_type ) = buildQuery([], [ 'pqf=@attr 1=1016 "Lessig"' ], [], [], [], 0, 'en');
524
    $query_type ) = buildQuery([], [ 'pqf=@attr 1=1016 "Lessig"' ], [], [], [], 0, 'en');
525
525
526
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
526
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
527
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords PQF author search for Lessig returned proper number of matches");
527
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords PQF author search for Lessig returned proper number of matches");
528
528
529
    ( $error, $query, $simple_query, $query_cgi,
529
    ( $error, $query, $simple_query, $query_cgi,
530
    $query_desc, $limit, $limit_cgi, $limit_desc,
530
    $query_desc, $limit, $limit_cgi, $limit_desc,
531
    $query_type ) = buildQuery([], [ 'ccl=au:Lessig' ], [], [], [], 0, 'en');
531
    $query_type ) = buildQuery([], [ 'ccl=au:Lessig' ], [], [], [], 0, 'en');
532
532
533
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
533
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
534
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CCL author search for Lessig returned proper number of matches");
534
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CCL author search for Lessig returned proper number of matches");
535
535
536
    ( $error, $query, $simple_query, $query_cgi,
536
    ( $error, $query, $simple_query, $query_cgi,
537
    $query_desc, $limit, $limit_cgi, $limit_desc,
537
    $query_desc, $limit, $limit_cgi, $limit_desc,
538
    $query_type ) = buildQuery([], [ 'cql=dc.author any lessig' ], [], [], [], 0, 'en');
538
    $query_type ) = buildQuery([], [ 'cql=dc.author any lessig' ], [], [], [], 0, 'en');
539
539
540
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
540
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
541
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CQL author search for Lessig returned proper number of matches");
541
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CQL author search for Lessig returned proper number of matches");
542
542
543
    $QueryStemming = $QueryAutoTruncate = $QueryFuzzy = 0;
543
    $QueryStemming = $QueryAutoTruncate = $QueryFuzzy = 0;
Lines 546-552 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
546
    $query_desc, $limit, $limit_cgi, $limit_desc,
546
    $query_desc, $limit, $limit_cgi, $limit_desc,
547
    $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [], [], 0, 'en');
547
    $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [], [], 0, 'en');
548
548
549
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
549
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
550
    is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results");
550
    is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results");
551
    is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
551
    is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
552
552
Lines 556-569 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
556
    $query_desc, $limit, $limit_cgi, $limit_desc,
556
    $query_desc, $limit, $limit_cgi, $limit_desc,
557
    $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
557
    $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
558
558
559
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
559
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
560
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic' returns matches  with automatic truncation on");
560
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic' returns matches  with automatic truncation on");
561
561
562
    ( $error, $query, $simple_query, $query_cgi,
562
    ( $error, $query, $simple_query, $query_cgi,
563
    $query_desc, $limit, $limit_cgi, $limit_desc,
563
    $query_desc, $limit, $limit_cgi, $limit_desc,
564
    $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
564
    $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
565
565
566
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
566
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
567
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation on");
567
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation on");
568
568
569
    $QueryStemming = $QueryFuzzy = $QueryAutoTruncate = 0;
569
    $QueryStemming = $QueryFuzzy = $QueryAutoTruncate = 0;
Lines 571-583 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
571
    ( $error, $query, $simple_query, $query_cgi,
571
    ( $error, $query, $simple_query, $query_cgi,
572
    $query_desc, $limit, $limit_cgi, $limit_desc,
572
    $query_desc, $limit, $limit_cgi, $limit_desc,
573
    $query_type ) = buildQuery([], [ 'web application' ], [ 'kw' ], [], [], 0, 'en');
573
    $query_type ) = buildQuery([], [ 'web application' ], [ 'kw' ], [], [], 0, 'en');
574
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
574
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
575
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web application' returns one hit with QueryWeightFields on");
575
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web application' returns one hit with QueryWeightFields on");
576
576
577
    ( $error, $query, $simple_query, $query_cgi,
577
    ( $error, $query, $simple_query, $query_cgi,
578
    $query_desc, $limit, $limit_cgi, $limit_desc,
578
    $query_desc, $limit, $limit_cgi, $limit_desc,
579
    $query_type ) = buildQuery([], [ 'web "application' ], [ 'kw' ], [], [], 0, 'en');
579
    $query_type ) = buildQuery([], [ 'web "application' ], [ 'kw' ], [], [], 0, 'en');
580
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
580
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
581
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web \"application' returns one hit with QueryWeightFields on (bug 7518)");
581
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web \"application' returns one hit with QueryWeightFields on (bug 7518)");
582
582
583
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0;
583
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0;
Lines 585-598 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
585
    $query_desc, $limit, $limit_cgi, $limit_desc,
585
    $query_desc, $limit, $limit_cgi, $limit_desc,
586
    $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
586
    $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
587
587
588
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
588
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
589
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'medic' returns no matches with automatic truncation off");
589
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'medic' returns no matches with automatic truncation off");
590
590
591
    ( $error, $query, $simple_query, $query_cgi,
591
    ( $error, $query, $simple_query, $query_cgi,
592
    $query_desc, $limit, $limit_cgi, $limit_desc,
592
    $query_desc, $limit, $limit_cgi, $limit_desc,
593
    $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
593
    $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
594
594
595
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
595
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
596
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation off");
596
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation off");
597
597
598
    $QueryStemming = $QueryWeightFields = 1;
598
    $QueryStemming = $QueryWeightFields = 1;
Lines 601-607 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
601
    $query_desc, $limit, $limit_cgi, $limit_desc,
601
    $query_desc, $limit, $limit_cgi, $limit_desc,
602
    $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
602
    $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
603
603
604
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
604
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
605
    is($results_hashref->{biblioserver}->{hits}, 7, "Search for 'pressed' returns matches when stemming (and query weighting) is on");
605
    is($results_hashref->{biblioserver}->{hits}, 7, "Search for 'pressed' returns matches when stemming (and query weighting) is on");
606
606
607
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0;
607
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0;
Lines 609-615 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
609
    $query_desc, $limit, $limit_cgi, $limit_desc,
609
    $query_desc, $limit, $limit_cgi, $limit_desc,
610
    $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
610
    $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
611
611
612
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
612
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
613
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'pressed' returns no matches when stemming is off");
613
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'pressed' returns no matches when stemming is off");
614
614
615
    ( $error, $query, $simple_query, $query_cgi,
615
    ( $error, $query, $simple_query, $query_cgi,
Lines 631-646 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
631
    isnt($error, undef, "SimpleSearch returns an error when passed gibberish");
631
    isnt($error, undef, "SimpleSearch returns an error when passed gibberish");
632
632
633
    warning_like {( undef, $results_hashref, $facets_loop ) =
633
    warning_like {( undef, $results_hashref, $facets_loop ) =
634
        getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'nonsense', undef) }
634
        getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'nonsense', undef) }
635
        qr/Unknown query_type/, "getRecords warns about unknown query type";
635
        qr/Unknown query_type/, "getRecords warns about unknown query type";
636
636
637
    warning_like {( undef, $results_hashref, $facets_loop ) =
637
    warning_like {( undef, $results_hashref, $facets_loop ) =
638
        getRecords('pqf=@attr 1=4 "title"', 'pqf=@attr 1=4 "title"', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, '', undef) }
638
        getRecords('pqf=@attr 1=4 "title"', 'pqf=@attr 1=4 "title"', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, '', undef) }
639
        qr/WARNING: query problem/, "getRecords warns when query type is not specified for non-CCL query";
639
        qr/WARNING: query problem/, "getRecords warns when query type is not specified for non-CCL query";
640
640
641
    # Let's just test a few other bits and bobs, just for fun
641
    # Let's just test a few other bits and bobs, just for fun
642
642
643
    ($error, $results_hashref, $facets_loop) = getRecords("Godzina pąsowej róży","Godzina pąsowej róży",[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
643
    ($error, $results_hashref, $facets_loop) = getRecords("Godzina pąsowej róży","Godzina pąsowej róży",[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
644
    @newresults = searchResults({'interface'=>'intranet'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
644
    @newresults = searchResults({'interface'=>'intranet'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
645
        $results_hashref->{'biblioserver'}->{"RECORDS"});
645
        $results_hashref->{'biblioserver'}->{"RECORDS"});
646
    is($newresults[0]->{'alternateholdings_count'}, 1, 'Alternate holdings filled in correctly');
646
    is($newresults[0]->{'alternateholdings_count'}, 1, 'Alternate holdings filled in correctly');
Lines 659-672 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
659
        }
659
        }
660
    });
660
    });
661
661
662
    ($error, $results_hashref, $facets_loop) = getRecords("TEST12121212","TEST12121212",[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
662
    ($error, $results_hashref, $facets_loop) = getRecords("TEST12121212","TEST12121212",[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
663
    @newresults = searchResults({'interface'=>'intranet'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
663
    @newresults = searchResults({'interface'=>'intranet'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
664
        $results_hashref->{'biblioserver'}->{"RECORDS"});
664
        $results_hashref->{'biblioserver'}->{"RECORDS"});
665
    ok(!exists($newresults[0]->{norequests}), 'presence of a transit does not block hold request action (bug 10741)');
665
    ok(!exists($newresults[0]->{norequests}), 'presence of a transit does not block hold request action (bug 10741)');
666
666
667
    ## Regression test for bug 10684
667
    ## Regression test for bug 10684
668
    ( undef, $results_hashref, $facets_loop ) =
668
    ( undef, $results_hashref, $facets_loop ) =
669
        getRecords('ti:punctuation', 'punctuation', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
669
        getRecords('ti:punctuation', 'punctuation', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'ccl', undef);
670
    is($results_hashref->{biblioserver}->{hits}, 1, "search for ti:punctuation returned expected number of records");
670
    is($results_hashref->{biblioserver}->{hits}, 1, "search for ti:punctuation returned expected number of records");
671
    warning_like { @newresults = searchResults({'intranet' => 'intranet'}, $query_desc,
671
    warning_like { @newresults = searchResults({'intranet' => 'intranet'}, $query_desc,
672
                    $results_hashref->{'biblioserver'}->{'hits'}, 20, 0, 0,
672
                    $results_hashref->{'biblioserver'}->{'hits'}, 20, 0, 0,
Lines 814-820 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
814
814
815
    # retrieve records that are larger than the MARC limit of 99,999 octets
815
    # retrieve records that are larger than the MARC limit of 99,999 octets
816
    ( undef, $results_hashref, $facets_loop ) =
816
    ( undef, $results_hashref, $facets_loop ) =
817
        getRecords('ti:marc the large record', '', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
817
        getRecords('ti:marc the large record', '', [], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef);
818
    is($results_hashref->{biblioserver}->{hits}, 1, "Can do a search that retrieves an over-large bib record (bug 11096)");
818
    is($results_hashref->{biblioserver}->{hits}, 1, "Can do a search that retrieves an over-large bib record (bug 11096)");
819
    @newresults = searchResults({'interface' =>'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 10, 0, 0,
819
    @newresults = searchResults({'interface' =>'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 10, 0, 0,
820
        $results_hashref->{'biblioserver'}->{"RECORDS"});
820
        $results_hashref->{'biblioserver'}->{"RECORDS"});
Lines 831-837 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
831
    # verify that we don't attempt to sort if no results were returned
831
    # verify that we don't attempt to sort if no results were returned
832
    # because of a query error
832
    # because of a query error
833
    warning_like {( undef, $results_hashref, $facets_loop ) =
833
    warning_like {( undef, $results_hashref, $facets_loop ) =
834
        getRecords('ccl=( AND )', '', ['title_az'], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef)
834
        getRecords('ccl=( AND )', '', ['title_az'], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef)
835
    } qr/WARNING: query problem with/, 'got warning instead of crash when attempting to run invalid query (bug 9578)';
835
    } qr/WARNING: query problem with/, 'got warning instead of crash when attempting to run invalid query (bug 9578)';
836
    
836
    
837
    # Test facet calculation
837
    # Test facet calculation
Lines 862-885 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
862
    # Test _get_facets_info
862
    # Test _get_facets_info
863
    my $facets_info = C4::Search::_get_facets_info( $facets );
863
    my $facets_info = C4::Search::_get_facets_info( $facets );
864
    my $expected_facets_info_marc21 = {
864
    my $expected_facets_info_marc21 = {
865
                   'au' => { 'expanded'    => undef,
865
                   'au' => { 'label_value' => "Authors" },
866
                             'label_value' => "Authors" },
866
                'ccode' => { 'label_value' => "CollectionCodes" },
867
                'ccode' => { 'expanded'    => undef,
867
        'holdingbranch' => { 'label_value' => "HoldingLibrary" },
868
                             'label_value' => "CollectionCodes" },
868
                'itype' => { 'label_value' => "ItemTypes" },
869
        'holdingbranch' => { 'expanded'    => undef,
869
             'location' => { 'label_value' => "Location" },
870
                             'label_value' => "HoldingLibrary" },
870
                   'se' => { 'label_value' => "Series" },
871
                'itype' => { 'expanded'    => undef,
871
               'su-geo' => { 'label_value' => "Places" },
872
                             'label_value' => "ItemTypes" },
872
                'su-to' => { 'label_value' => "Topics" },
873
             'location' => { 'expanded'    => undef,
873
                'su-ut' => { 'label_value' => "Titles" }
874
                             'label_value' => "Location" },
875
                   'se' => { 'expanded'    => undef,
876
                             'label_value' => "Series" },
877
               'su-geo' => { 'expanded'    => undef,
878
                             'label_value' => "Places" },
879
                'su-to' => { 'expanded'    => undef,
880
                             'label_value' => "Topics" },
881
                'su-ut' => { 'expanded'    => undef,
882
                             'label_value' => "Titles" }
883
    };
874
    };
884
    delete $expected_facets_info_marc21->{holdingbranch}
875
    delete $expected_facets_info_marc21->{holdingbranch}
885
        if Koha::Libraries->count == 1;
876
        if Koha::Libraries->count == 1;
Lines 961-982 sub run_unimarc_search_tests { Link Here
961
    my $facets      = C4::Koha::getFacets();
952
    my $facets      = C4::Koha::getFacets();
962
    my $facets_info = C4::Search::_get_facets_info( $facets );
953
    my $facets_info = C4::Search::_get_facets_info( $facets );
963
    my $expected_facets_info_unimarc = {
954
    my $expected_facets_info_unimarc = {
964
                   'au' => { 'expanded'    => undef,
955
                   'au' => { 'label_value' => "Authors" },
965
                             'label_value' => "Authors" },
956
                'ccode' => { 'label_value' => "CollectionCodes" },
966
                'ccode' => { 'expanded'    => undef,
957
        'holdingbranch' => { 'label_value' => "HoldingLibrary" },
967
                             'label_value' => "CollectionCodes" },
958
             'location' => { 'label_value' => "Location" },
968
        'holdingbranch' => { 'expanded'    => undef,
959
                   'se' => { 'label_value' => "Series" },
969
                             'label_value' => "HoldingLibrary" },
960
               'su-geo' => { 'label_value' => "Places" },
970
             'location' => { 'expanded'    => undef,
961
                'su-to' => { 'label_value' => "Topics" },
971
                             'label_value' => "Location" },
962
                'su-ut' => { 'label_value' => "Titles" }
972
                   'se' => { 'expanded'    => undef,
973
                             'label_value' => "Series" },
974
               'su-geo' => { 'expanded'    => undef,
975
                             'label_value' => "Places" },
976
                'su-to' => { 'expanded'    => undef,
977
                             'label_value' => "Topics" },
978
                'su-ut' => { 'expanded'    => undef,
979
                             'label_value' => "Titles" }
980
    };
963
    };
981
    delete $expected_facets_info_unimarc->{holdingbranch}
964
    delete $expected_facets_info_unimarc->{holdingbranch}
982
        if Koha::Libraries->count == 1;
965
        if Koha::Libraries->count == 1;
983
- 

Return to bug 14419