Bug 24031: Add safety checks in Koha::Plugins::call
[koha.git] / Koha / SearchEngine / Zebra / Search.pm
blob850469ec5d8ce855cab0bef6648ef5d42f1ce536
1 package Koha::SearchEngine::Zebra::Search;
3 # This file is part of Koha.
5 # Copyright 2012 BibLibre
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.
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.
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>.
20 use Modern::Perl;
22 use base qw(Class::Accessor);
24 use C4::Search; # :(
25 use C4::AuthoritiesMarc;
26 use Koha::SearchEngine::Search;
28 =head1 NAME
30 Koha::SearchEngine::Zebra::Search - Search implementation for Zebra
32 =head1 METHODS
34 =head2 search
36 =cut
38 sub search {
39 my ($self,$query_string) = @_;
41 my $query = Data::SearchEngine::Query->new(
42 count => 10,
43 page => 1,
44 query => $query_string,
47 my $results = $self->searchengine->search($query);
49 foreach my $item (@{ $results->items }) {
50 my $title = $item->get_value('ste_title');
51 #utf8::encode($title);
52 print "$title\n";
56 =head2 search_compat
58 This passes straight through to C4::Search::getRecords.
60 =cut
62 sub search_compat {
63 shift; # get rid of $self
65 return getRecords(@_);
68 =head2 simple_search_compat
70 This passes straight through to C4::Search::SimpleSearch.
72 =cut
75 sub simple_search_compat {
76 shift;
77 return C4::Search::SimpleSearch(@_);
80 =head2 extract_biblionumber
82 my $biblionumber = $searcher->extract_biblionumber( $searchresult );
84 $searchresult comes from simple_search_compat.
86 Returns the biblionumber from the search result record.
88 =cut
90 sub extract_biblionumber {
91 my ( $self, $searchresultrecord ) = @_;
92 my $record = C4::Search::new_record_from_zebra( 'biblioserver', $searchresultrecord );
93 return Koha::SearchEngine::Search::extract_biblionumber( $record );
96 =head2 search_auth_compat
98 This passes the search query on to C4::AuthoritiesMarc::SearchAuthorities
100 =cut
102 sub search_auth_compat {
103 my ( $self, $q, $startfrom, $resperpage, $skipmetadata ) = @_;
105 my @params = (
106 @{$q}{ 'marclist', 'and_or', 'excluding', 'operator', 'value' },
107 $startfrom - 1,
108 $resperpage, @{$q}{ 'authtypecode', 'orderby' }, $skipmetadata
110 C4::AuthoritiesMarc::SearchAuthorities(@params);
113 =head2 max_result_window
115 Returns the maximum number of results that can be fetched
117 Zebra does not have such a limit, so it always returns undef
119 =cut
121 sub max_result_window { undef }