@@ -, +, @@ -- type X into field Y -- click button Z -- click downdrop W -- select item V -- enter 'text' into text box labelled A authority server, Koha will now find none." --- Koha/SearchEngine/Zebra/Search.pm | 45 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) --- a/Koha/SearchEngine/Zebra/Search.pm +++ a/Koha/SearchEngine/Zebra/Search.pm @@ -21,13 +21,48 @@ use Modern::Perl; use base qw(Class::Accessor); +# Added index accessor, because base isn't Koha::SearchEngine +# Because of nasty nested loopy dependencies that would +# break things if it was changed right now. +__PACKAGE__->mk_ro_accessors(qw( index )); + use C4::Search; # :( use C4::AuthoritiesMarc; +use Carp; =head1 NAME Koha::SearchEngine::Zebra::Search - Search implementation for Zebra +=head1 ACCESSORS + +=over 4 + +=item index + +The name of the index to use, generally 'biblios' or 'authorities'. +It is provided as a parameter when this is instantiated. + + my $index = 'authorities'; # could be 'biblios' + my $searcher = + Koha::SearchEngine::Zebra::Search->new( { index => $index } ); + +=back + +=cut + +sub new { + my @parameters = @_; + my $class = shift @parameters; + my $self = $class->SUPER::new(@parameters); + + # Check for a valid index + if ( !defined $self->index ) { + croak('No index name provided'); + } + return $self; +} + =head1 METHODS =head2 search @@ -72,8 +107,14 @@ This passes straight through to C4::Search::SimpleSearch. sub simple_search_compat { - shift; - return C4::Search::SimpleSearch(@_); + my @parameters = @_; + my $self = shift @parameters; + + # default is ['biblioserver'], so just fix authorities. + if ( $self->index eq 'authorities' ) { + push @parameters, ['authorityserver']; + } + return C4::Search::SimpleSearch(@parameters); } =head2 search_auth_compat --