$query= "an:".$authid;
# Should really be replaced with a real count call, this is a
# bad way.
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
my ($err,$res,$result) = $searcher->simple_search_compat($query,0,1);
if ($err) {
warn "Error: $err from search $query";
$_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
}
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::AUTHORITIES_INDEX});
my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::AUTHORITIES_INDEX});
my ($error, $results, $total_hits) = $searcher->simple_search_compat( $query, 0, 1 );
# there is at least 1 result => return the 1st one
if (!defined $error && @{$results} ) {
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new(
{
index => $server eq 'biblioserver'
? $Koha::SearchEngine::BIBLIOS_INDEX
? Koha::SearchEngine::BIBLIOS_INDEX
: $Koha::SearchEngine::AUTHORITIES_INDEX
: Koha::SearchEngine::AUTHORITIES_INDEX
);
if ( $op eq 'specialUpdate' ) {
### ZOOM search here
my $query;
$query= "hi=".$itemnumber;
my ($err,$res,$result) = $searcher->simple_search_compat($query,0,10);
return ($result);
#NOTE: double-quote the values so you don't get a "Embedded truncation not supported" error when a term has a ? in it.
( $error, $searchresults, $total_hits ) =
$searcher->simple_search_compat( $query, 0, $max_matches );
my $xisbn = shift;
my $dbh = C4::Context->dbh;
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 1 );
return unless ( !$errors && scalar @$results );
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Readonly;
=head1 NAME
# Search engine implementations should compare against these to determine
# what bit of storage is being requested. They will be sensible strings so
# may be used for, e.g., directory names.
Readonly our $BIBLIOS_INDEX => 'biblios';
use constant {
Readonly our $AUTHORITIES_INDEX => 'authorities';
BIBLIOS_INDEX => 'biblios',
AUTHORITIES_INDEX => 'authorities',
};
use Carp;
use JSON;
use YAML::Syck;
use Data::Dumper; # TODO remove
__PACKAGE__->mk_accessors(qw( sort_fields ));
# Constants to refer to the standard index names
=head1 SYNOPSIS
use Koha::SearchEngine::QueryBuilder;
my $qb = Koha::SearchEngine::QueryBuilder->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
my $qb = Koha::SearchEngine::QueryBuilder->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
=head1 METHODS
my $QParser;
$QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
my $builtquery;
my $builder = Koha::SearchEngine::QueryBuilder->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
my $builder = Koha::SearchEngine::QueryBuilder->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
if ($QParser) {
$builtquery = $query;
} else {
my $resultsperpage = $query->param('resultsperpage') || 20;
my $builder = Koha::SearchEngine::QueryBuilder->new(
{ index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
{ index => Koha::SearchEngine::AUTHORITIES_INDEX } );
my $searcher = Koha::SearchEngine::Search->new(
my $search_query = $builder->build_authorities_query_compat(
[$marclist], [$and_or], [$excluding], [$operator],
[$value], $authtypecode, $orderby
$query= "an=".$authority->{'authid'};
# search for biblios mapped
my ($err,undef,$used) = $searcher->simple_search_compat($query,0,1);
if (defined $err) {
$used = 0;
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
{ index => $Koha::SearchEngine::BIBLIOS_INDEX } );
{ index => Koha::SearchEngine::BIBLIOS_INDEX } );
## I. BUILD THE QUERY
(
$op = 'and';
$search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype;
my ( $errors, $results, $total_hits ) =
$searcher->simple_search_compat( $search,
$search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype;
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($search, $startfrom * $resultsperpage, $resultsperpage );
if (defined $errors ) {
$results = [];
$template_params->{FALLBACK} = 1;
my $query = "kw=" . $barcode;
my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
index => (
$authorities
? $Koha::SearchEngine::AUTHORITIES_INDEX
? Koha::SearchEngine::AUTHORITIES_INDEX
: $Koha::SearchEngine::BIBLIOS_INDEX
: Koha::SearchEngine::BIBLIOS_INDEX
)
$records->next();
do_reindex($next, $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX);
do_reindex($next, Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX);
if ($index_authorities) {
_log(1, "Indexing authorities\n");
do_reindex($next, $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
do_reindex($next, Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
sub do_reindex {
my @tags;
my $search_query = $builder->build_authorities_query_compat( \@marclist, \@and_or,
\@excluding, \@operator, \@value, $authtypecode, $orderby );
my $offset = ( $startfrom - 1 ) * $resultsperpage + 1;
$resultsperpage = $input->param('resultsperpage');
$resultsperpage = 20 if ( !defined $resultsperpage );
my ( $error, $marcrecords, $total_hits ) =
$searcher->simple_search_compat( $query, $startfrom * $resultsperpage, $resultsperpage );
my $total = 0;
-