Bug 16489: ES code incorrectly refers to Moose
[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 use Modern::Perl;
21
22 use base qw(Class::Accessor);
23
24 use C4::Search; # :(
25 use C4::AuthoritiesMarc;
26
27 =head1 NAME
28
29 Koha::SearchEngine::Zebra::Search - Search implementation for Zebra
30
31 =head1 METHODS
32
33 =head2 search
34
35 =cut
36
37 sub search {
38     my ($self,$query_string) = @_;
39
40      my $query = Data::SearchEngine::Query->new(
41        count => 10,
42        page => 1,
43        query => $query_string,
44      );
45
46     my $results = $self->searchengine->search($query);
47
48     foreach my $item (@{ $results->items }) {
49         my $title = $item->get_value('ste_title');
50         #utf8::encode($title);
51         print "$title\n";
52     }
53 }
54
55 =head2 search_compat
56
57 This passes straight through to C4::Search::getRecords.
58
59 =cut
60
61 sub search_compat {
62     shift; # get rid of $self
63
64     return getRecords(@_);
65 }
66
67 =head2 simple_search_compat
68
69 This passes straight through to C4::Search::SimpleSearch.
70
71 =cut
72
73
74 sub simple_search_compat {
75     shift;
76     return C4::Search::SimpleSearch(@_);
77 }
78
79 =head2 search_auth_compat
80
81 This passes the search query on to C4::AuthoritiesMarc::SearchAuthorities
82
83 =cut
84
85 sub search_auth_compat {
86     my ( $self, $q, $startfrom, $resperpage ) = @_;
87
88     my @params = (
89         @{$q}{ 'marclist', 'and_or', 'excluding', 'operator', 'value' },
90         $startfrom - 1,
91         $resperpage, @{$q}{ 'authtypecode', 'orderby' }
92     );
93     C4::AuthoritiesMarc::SearchAuthorities(@params);
94 }
95
96 1;