Sfoglia il codice sorgente
* admin/searchengine/elasticsearch/mappings.yaml: * Fix indentation so QA tools believe it's valid YAML * C4::AuthoritiesMarc: Remove tab character * C4::Search: Fix POD * Koha::BiblioUtils: remove "return undef" * Koha::Schema::Result::Search*: rename type to _type * Koha::SE::ES::Search: * Fix spelling/@_[0] * Add my to loop variable * Remove unused var $error * Add use Modern::Perl * Fix undefined variables * Koha::ES::Indexer: fix POD * Koha::SE::ES::QueryBuilder: * Don't define variables in conditionals * Fix POD * Koha::SE::Zebra::Search: * Fix debug warns/POD/barewords * Koha::SE::Zebra::Search: add use Modern::Perl * kohastructure.sql: remove old, unused elasticsearch_mappings table, add new tables * labels/label-item-search.pl: remove C4::Dates * opac/elasticsearch.pl: remove old file Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>16.05.x
Jesse Weaver
8 anni fa
committato da
Brendan Gallagher
15 ha cambiato i file con 2468 aggiunte e 2529 eliminazioni
File diff soppresso perché troppo grande
@ -1,102 +0,0 @@ |
|||
#!/usr/bin/perl |
|||
|
|||
# Copyright 2013 Catalyst |
|||
# |
|||
# This file is part of Koha. |
|||
# |
|||
# Koha is free software; you can redistribute it and/or modify it under the |
|||
# terms of the GNU General Public License as published by the Free Software |
|||
# Foundation; either version 3 of the License, or (at your option) any later |
|||
# version. |
|||
# |
|||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
|||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
|||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License along |
|||
# with Koha; if not, write to the Free Software Foundation, Inc., |
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
|
|||
use Modern::Perl; |
|||
|
|||
use C4::Context; |
|||
use CGI; |
|||
use C4::Auth; |
|||
use C4::Koha; |
|||
use C4::Output; |
|||
|
|||
# TODO this should use the moose thing that auto-picks. |
|||
use Koha::SearchEngine::Elasticsearch::QueryBuilder; |
|||
use Koha::ElasticSearch::Search; |
|||
|
|||
my $cgi = new CGI; |
|||
|
|||
my $template_name; |
|||
my $template_type = "basic"; |
|||
if ( $cgi->param("idx") or $cgi->param("q") ) { |
|||
$template_name = 'search/results.tt'; |
|||
} |
|||
else { |
|||
$template_name = 'search/advsearch.tt'; |
|||
$template_type = 'advsearch'; |
|||
} |
|||
|
|||
# load the template |
|||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
|||
{ |
|||
template_name => $template_name, |
|||
query => $cgi, |
|||
type => "opac", |
|||
authnotrequired => 1, |
|||
} |
|||
); |
|||
my %template_params; |
|||
my $format = $cgi->param("format") || 'html'; |
|||
|
|||
# load the Type stuff |
|||
my $itemtypes = GetItemTypes; |
|||
|
|||
my $page = $cgi->param("page") || 1; |
|||
my $count = |
|||
$cgi->param('count') |
|||
|| C4::Context->preference('OPACnumSearchResults') |
|||
|| 20; |
|||
my $q = $cgi->param("q"); |
|||
|
|||
my $searcher = Koha::ElasticSearch::Search->new(); |
|||
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new(); |
|||
my $query; |
|||
if ($cgi->param('type') eq 'browse') { |
|||
$query = $builder->build_browse_query($cgi->param('browse_field') || undef, $q ); |
|||
$template_params{browse} = 1; |
|||
} else { |
|||
$query = $builder->build_query($q); |
|||
} |
|||
my $results = $searcher->search( $query, $page, $count ); |
|||
#my $results = $searcher->search( { "match_phrase_prefix" => { "title" => "the" } } ); |
|||
|
|||
# This is temporary, but will do the job for now. |
|||
my @hits; |
|||
$results->each(sub { |
|||
push @hits, { _source => @_[0] }; |
|||
}); |
|||
# Make a list of the page numbers |
|||
my @pages = map { { page => $_, current => ($_ == ( $page || 1)) } } 1 .. int($results->total / $count); |
|||
my $max_page = int($results->total / $count); |
|||
# Pager template params |
|||
$template->param( |
|||
SEARCH_RESULTS => \@hits, |
|||
PAGE_NUMBERS => \@pages, |
|||
total => $results->total, |
|||
previous_page => ( $page > 1 ? $page - 1 : undef ), |
|||
next_page => ( $page < $max_page ? $page + 1 : undef ), |
|||
follower_params => [ |
|||
{ var => 'type', val => $cgi->param('type') }, |
|||
{ var => 'q', val => $q }, |
|||
{ var => 'count', val => $count }, |
|||
], |
|||
%template_params, |
|||
); |
|||
|
|||
my $content_type = ( $format eq 'rss' or $format eq 'atom' ) ? $format : 'html'; |
|||
output_with_http_headers $cgi, $cookie, $template->output, $content_type; |
Caricamento…
Reference in new issue