Bug 12748: (QA followup) fix several tiny QA tools warnings
[koha.git] / Koha / SearchEngine / Zebra / Search.pm
1 package Koha::SearchEngine::Zebra::Search;
2
3 # This file is part of Koha.
4 #
5 # Copyright 2012 BibLibre
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 # I don't think this ever worked right
21 #use Moose::Role;
22 #with 'Koha::SearchEngine::SearchRole';
23
24 use Modern::Perl;
25
26 use base qw(Class::Accessor);
27
28 use C4::Search; # :(
29 use C4::AuthoritiesMarc;
30
31 =head1 NAME
32
33 Koha::SearchEngine::Zebra::Search - Search implementation for Zebra
34
35 =head1 METHODS
36
37 =head2 search
38
39 =cut
40
41 sub search {
42     my ($self,$query_string) = @_;
43
44      my $query = Data::SearchEngine::Query->new(
45        count => 10,
46        page => 1,
47        query => $query_string,
48      );
49
50     my $results = $self->searchengine->search($query);
51
52     foreach my $item (@{ $results->items }) {
53         my $title = $item->get_value('ste_title');
54         #utf8::encode($title);
55         print "$title\n";
56     }
57 }
58
59 =head2 search_compat
60
61 This passes straight through to C4::Search::getRecords.
62
63 =cut
64
65 sub search_compat {
66     shift; # get rid of $self
67
68     return getRecords(@_);
69 }
70
71 =head2 simple_search_compat
72
73 This passes straight through to C4::Search::SimpleSearch.
74
75 =cut
76
77
78 sub simple_search_compat {
79     shift;
80     return C4::Search::SimpleSearch(@_);
81 }
82
83 =head2 search_auth_compat
84
85 This passes the search query on to C4::AuthoritiesMarc::SearchAuthorities
86
87 =cut
88
89 sub search_auth_compat {
90     my ( $self, $q, $startfrom, $resperpage ) = @_;
91
92     my @params = (
93         @{$q}{ 'marclist', 'and_or', 'excluding', 'operator', 'value' },
94         $startfrom - 1,
95         $resperpage, @{$q}{ 'authtypecode', 'orderby' }
96     );
97     C4::AuthoritiesMarc::SearchAuthorities(@params);
98 }
99
100 1;