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

(-)a/C4/Search.pm (+9 lines)
Lines 625-630 sub getRecords { Link Here
625
                }
625
                }
626
            }
626
            }
627
        );
627
        );
628
629
    # This sorts the facets into alphabetical order
630
    if (@facets_loop) {
631
        foreach my $f (@facets_loop) {
632
            $f->{facets} = [ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ];
633
        }
634
        @facets_loop = sort {$a->{expand} cmp $b->{expand}} @facets_loop;
635
    }
636
628
    return ( undef, $results_hashref, \@facets_loop );
637
    return ( undef, $results_hashref, \@facets_loop );
629
}
638
}
630
639
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-10 / +14 lines)
Lines 391-403 sub _convert_facets { Link Here
391
391
392
    # These should correspond to the ES field names, as opposed to the CCL
392
    # These should correspond to the ES field names, as opposed to the CCL
393
    # things that zebra uses.
393
    # things that zebra uses.
394
    # TODO let the library define the order using the interface.
394
    my %type_to_label = (
395
    my %type_to_label = (
395
        author   => 'Authors',
396
        author   => { order => 1, label => 'Authors', },
396
        location => 'Location',
397
        itype    => { order => 2, label => 'ItemTypes', },
397
        itype    => 'ItemTypes',
398
        location => { order => 3, label => 'Location', },
398
        se       => 'Series',
399
        'su-geo' => { order => 4, label => 'Places', },
399
        subject  => 'Topics',
400
        se       => { order => 5, label => 'Series', },
400
        'su-geo' => 'Places',
401
        subject  => { order => 6, label => 'Topics', },
401
    );
402
    );
402
403
403
    # We also have some special cases, e.g. itypes that need to show the
404
    # We also have some special cases, e.g. itypes that need to show the
Lines 409-415 sub _convert_facets { Link Here
409
        itype    => { map { $_->itemtype         => $_->description } @itypes },
410
        itype    => { map { $_->itemtype         => $_->description } @itypes },
410
        location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations },
411
        location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations },
411
    );
412
    );
412
    my @res;
413
    my @facets;
413
    $exp_facet //= '';
414
    $exp_facet //= '';
414
    while ( ( $type, $data ) = each %$es ) {
415
    while ( ( $type, $data ) = each %$es ) {
415
        next if !exists( $type_to_label{$type} );
416
        next if !exists( $type_to_label{$type} );
Lines 421-428 sub _convert_facets { Link Here
421
            expand     => $type,
422
            expand     => $type,
422
            expandable => ( $type ne $exp_facet )
423
            expandable => ( $type ne $exp_facet )
423
              && ( @{ $data->{terms} } > $limit ),
424
              && ( @{ $data->{terms} } > $limit ),
424
            "type_label_$type_to_label{$type}" => 1,
425
            "type_label_$type_to_label{$type}{label}" => 1,
425
            type_link_value                    => $type,
426
            type_link_value                    => $type,
427
            order      => $type_to_label{$type}{order},
426
        };
428
        };
427
        $limit = @{ $data->{terms} } if ( $limit > @{ $data->{terms} } );
429
        $limit = @{ $data->{terms} } if ( $limit > @{ $data->{terms} } );
428
        foreach my $term ( @{ $data->{terms} }[ 0 .. $limit - 1 ] ) {
430
        foreach my $term ( @{ $data->{terms} }[ 0 .. $limit - 1 ] ) {
Lines 443-451 sub _convert_facets { Link Here
443
                type_link_value => $type,
445
                type_link_value => $type,
444
            };
446
            };
445
        }
447
        }
446
        push @res, $facet if exists $facet->{facets};
448
        push @facets, $facet if exists $facet->{facets};
447
    }
449
    }
448
    return \@res;
450
451
    @facets = sort { $a->{order} cmp $b->{order} } @facets;
452
    return \@facets;
449
}
453
}
450
454
451
455
(-)a/catalogue/search.pl (-6 lines)
Lines 484-495 eval { Link Here
484
    );
484
    );
485
};
485
};
486
486
487
# This sorts the facets into alphabetical order
488
if ($facets) {
489
    foreach my $f (@$facets) {
490
        $f->{facets} = [ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ];
491
    }
492
}
493
if ($@ || $error) {
487
if ($@ || $error) {
494
    $template->param(query_error => $error.$@);
488
    $template->param(query_error => $error.$@);
495
    output_html_with_http_headers $cgi, $cookie, $template->output;
489
    output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/opac/opac-search.pl (-9 lines)
Lines 589-602 if ($tag) { Link Here
589
    };
589
    };
590
}
590
}
591
591
592
# This sorts the facets into alphabetical order
593
if ($facets && @$facets) {
594
    foreach my $f (@$facets) {
595
        $f->{facets} = [ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ];
596
    }
597
    @$facets = sort {$a->{expand} cmp $b->{expand}} @$facets;
598
}
599
600
# use Data::Dumper; print STDERR "-" x 25, "\n", Dumper($results_hashref);
592
# use Data::Dumper; print STDERR "-" x 25, "\n", Dumper($results_hashref);
601
if ($@ || $error) {
593
if ($@ || $error) {
602
    $template->param(query_error => $error.$@);
594
    $template->param(query_error => $error.$@);
603
- 

Return to bug 12478