@@ -, +, @@ --- C4/Biblio.pm | 2 +- C4/Installer/PerlDependencies.pm | 40 ---- Koha/SearchEngine.pm | 46 ----- Koha/SearchEngine/Config.pm | 29 --- Koha/SearchEngine/ConfigRole.pm | 24 --- Koha/SearchEngine/FacetsBuilder.pm | 29 --- Koha/SearchEngine/FacetsBuilderRole.pm | 24 --- Koha/SearchEngine/Index.pm | 29 --- Koha/SearchEngine/IndexRole.pm | 24 --- Koha/SearchEngine/QueryBuilder.pm | 29 --- Koha/SearchEngine/QueryBuilderRole.pm | 24 --- Koha/SearchEngine/Search.pm | 30 --- Koha/SearchEngine/SearchRole.pm | 25 --- Koha/SearchEngine/Solr.pm | 63 ------ Koha/SearchEngine/Solr/Config.pm | 132 ------------ Koha/SearchEngine/Solr/FacetsBuilder.pm | 58 ------ Koha/SearchEngine/Solr/Index.pm | 126 ------------ Koha/SearchEngine/Solr/QueryBuilder.pm | 163 --------------- Koha/SearchEngine/Solr/Search.pm | 128 ------------ Koha/SearchEngine/Zebra.pm | 32 --- Koha/SearchEngine/Zebra/QueryBuilder.pm | 31 --- Koha/SearchEngine/Zebra/Search.pm | 58 ------ admin/admin-home.pl | 2 - admin/searchengine/solr/indexes.pl | 103 ---------- debian/rules | 3 - etc/searchengine/solr/config.yaml | 1 - etc/searchengine/solr/indexes.yaml | 45 ----- etc/searchengine/solr/indexes.yaml.bak | 33 --- installer/data/mysql/sysprefs.sql | 1 - installer/data/mysql/updatedatabase.pl | 10 + .../prog/en/modules/admin/admin-home.tt | 4 - .../prog/en/modules/admin/preferences/admin.pref | 8 - .../en/modules/admin/searchengine/solr/indexes.tt | 222 --------------------- .../opac-tmpl/prog/en/includes/search/facets.inc | 56 ------ .../prog/en/includes/search/page-numbers.inc | 17 -- .../prog/en/includes/search/resort_form.inc | 23 --- misc/migration_tools/rebuild_solr.pl | 179 ----------------- opac/opac-search.pl | 12 -- opac/search.pl | 172 ---------------- t/00-load.t | 1 - t/searchengine/000_conn/conn.t | 23 --- t/searchengine/001_search/search_base.t | 12 -- t/searchengine/002_index/index_base.t | 15 -- t/searchengine/003_query/buildquery.t | 44 ---- t/searchengine/004_config/load_config.t | 53 ----- t/searchengine/indexes.yaml | 33 --- 46 files changed, 11 insertions(+), 2207 deletions(-) delete mode 100644 Koha/SearchEngine.pm delete mode 100644 Koha/SearchEngine/Config.pm delete mode 100644 Koha/SearchEngine/ConfigRole.pm delete mode 100644 Koha/SearchEngine/FacetsBuilder.pm delete mode 100644 Koha/SearchEngine/FacetsBuilderRole.pm delete mode 100644 Koha/SearchEngine/Index.pm delete mode 100644 Koha/SearchEngine/IndexRole.pm delete mode 100644 Koha/SearchEngine/QueryBuilder.pm delete mode 100644 Koha/SearchEngine/QueryBuilderRole.pm delete mode 100644 Koha/SearchEngine/Search.pm delete mode 100644 Koha/SearchEngine/SearchRole.pm delete mode 100644 Koha/SearchEngine/Solr.pm delete mode 100644 Koha/SearchEngine/Solr/Config.pm delete mode 100644 Koha/SearchEngine/Solr/FacetsBuilder.pm delete mode 100644 Koha/SearchEngine/Solr/Index.pm delete mode 100644 Koha/SearchEngine/Solr/QueryBuilder.pm delete mode 100644 Koha/SearchEngine/Solr/Search.pm delete mode 100644 Koha/SearchEngine/Zebra.pm delete mode 100644 Koha/SearchEngine/Zebra/QueryBuilder.pm delete mode 100644 Koha/SearchEngine/Zebra/Search.pm delete mode 100755 admin/searchengine/solr/indexes.pl delete mode 100644 etc/searchengine/solr/config.yaml delete mode 100644 etc/searchengine/solr/indexes.yaml delete mode 100644 etc/searchengine/solr/indexes.yaml.bak delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/solr/indexes.tt delete mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/search/facets.inc delete mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/search/page-numbers.inc delete mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/search/resort_form.inc delete mode 100755 misc/migration_tools/rebuild_solr.pl delete mode 100755 opac/search.pl delete mode 100644 t/searchengine/000_conn/conn.t delete mode 100755 t/searchengine/001_search/search_base.t delete mode 100755 t/searchengine/002_index/index_base.t delete mode 100644 t/searchengine/003_query/buildquery.t delete mode 100644 t/searchengine/004_config/load_config.t delete mode 100644 t/searchengine/indexes.yaml --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -663,7 +663,7 @@ sub LinkBibHeadingsToAuthorities { } Check whether the specified heading-auth link is valid without reference -to Zebra/Solr. Ideally this code would be in C4::Heading, but that won't be +to Zebra. Ideally this code would be in C4::Heading, but that won't be possible until we have de-cycled C4::AuthoritiesMarc, so this is the safest place. --- a/C4/Installer/PerlDependencies.pm +++ a/C4/Installer/PerlDependencies.pm @@ -552,51 +552,11 @@ our $PERL_DEPS = { 'required' => '1', 'min_ver' => '0.03', }, - 'Data::Paginator' => { - 'usage' => 'Core', - 'required' => '0', - 'min_ver' => '0.04', - }, - 'Data::Pagination' => { - 'usage' => 'Core', - 'required' => '0', - 'min_ver' => '0.44', - }, - 'JSON::Any' => { - 'usage' => 'Core', - 'required' => '0', - 'min_ver' => '1.28', - }, - 'MooseX::Storage' => { - 'usage' => 'Core', - 'required' => '0', - 'min_ver' => '0.30', - }, - 'MooseX::Types' => { - 'usage' => 'Core', - 'required' => '0', - 'min_ver' => '0.30', - }, - 'String::RewritePrefix' => { - 'usage' => 'Core', - 'required' => '0', - 'min_ver' => '0.006', - }, - 'Time::Progress' => { - 'usage' => 'Core', - 'required' => '0', - 'min_ver' => '1.7', - }, 'DBD::Mock' => { 'usage' => 'Core', 'required' => '1', 'min_ver' => '1.39' }, - 'Test::MockModule' => { - 'usage' => 'Core', - 'required' => '1', - 'min_ver' => '0.05', - }, 'Test::Warn' => { 'usage' => 'Core', 'required' => '0', --- a/Koha/SearchEngine.pm +++ a/Koha/SearchEngine.pm @@ -1,46 +0,0 @@ -package Koha::SearchEngine; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; -use C4::Context; -use Koha::SearchEngine::Config; - -has 'name' => ( - is => 'ro', - default => sub { - C4::Context->preference('SearchEngine'); - } -); - -has config => ( - is => 'rw', - lazy => 1, - default => sub { - Koha::SearchEngine::Config->new; - } -# lazy => 1, -# builder => '_build_config', -); - -#sub _build_config { -# my ( $self ) = @_; -# Koha::SearchEngine::Config->new( $self->name ); -#); - -1; --- a/Koha/SearchEngine/Config.pm +++ a/Koha/SearchEngine/Config.pm @@ -1,29 +0,0 @@ -package Koha::SearchEngine::Config; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; - -use Moose::Util qw( apply_all_roles ); - -sub BUILD { - my $self = shift; - my $syspref = C4::Context->preference("SearchEngine"); - apply_all_roles( $self, "Koha::SearchEngine::${syspref}::Config" ); -}; -1; --- a/Koha/SearchEngine/ConfigRole.pm +++ a/Koha/SearchEngine/ConfigRole.pm @@ -1,24 +0,0 @@ -package Koha::SearchEngine::ConfigRole; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose::Role; - -requires 'indexes', 'index', 'ressource_types'; - -1; --- a/Koha/SearchEngine/FacetsBuilder.pm +++ a/Koha/SearchEngine/FacetsBuilder.pm @@ -1,29 +0,0 @@ -package Koha::SearchEngine::FacetsBuilder; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; - -use Moose::Util qw( apply_all_roles ); - -sub BUILD { - my $self = shift; - my $syspref = C4::Context->preference("SearchEngine"); - apply_all_roles( $self, "Koha::SearchEngine::${syspref}::FacetsBuilder" ); -}; -1; --- a/Koha/SearchEngine/FacetsBuilderRole.pm +++ a/Koha/SearchEngine/FacetsBuilderRole.pm @@ -1,24 +0,0 @@ -package Koha::SearchEngine::FacetsBuilderRole; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose::Role; - -requires 'build_facets'; - -1; --- a/Koha/SearchEngine/Index.pm +++ a/Koha/SearchEngine/Index.pm @@ -1,29 +0,0 @@ -package Koha::SearchEngine::Index; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; - -use Moose::Util qw( apply_all_roles ); - -sub BUILD { - my $self = shift; - my $syspref = 'Solr'; - apply_all_roles( $self, "Koha::SearchEngine::${syspref}::Index" ); -}; -1; --- a/Koha/SearchEngine/IndexRole.pm +++ a/Koha/SearchEngine/IndexRole.pm @@ -1,24 +0,0 @@ -package Koha::SearchEngine::IndexRole; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose::Role; - -requires 'index_record'; - -1; --- a/Koha/SearchEngine/QueryBuilder.pm +++ a/Koha/SearchEngine/QueryBuilder.pm @@ -1,29 +0,0 @@ -package Koha::SearchEngine::QueryBuilder; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; - -use Moose::Util qw( apply_all_roles ); - -sub BUILD { - my $self = shift; - my $syspref = C4::Context->preference("SearchEngine"); - apply_all_roles( $self, "Koha::SearchEngine::${syspref}::QueryBuilder" ); -}; -1; --- a/Koha/SearchEngine/QueryBuilderRole.pm +++ a/Koha/SearchEngine/QueryBuilderRole.pm @@ -1,24 +0,0 @@ -package Koha::SearchEngine::QueryBuilderRole; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose::Role; - -requires 'build_query'; - -1; --- a/Koha/SearchEngine/Search.pm +++ a/Koha/SearchEngine/Search.pm @@ -1,30 +0,0 @@ -package Koha::SearchEngine::Search; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; -use C4::Context; - -use Moose::Util qw( apply_all_roles ); - -sub BUILD { - my $self = shift; - my $syspref = C4::Context->preference("SearchEngine"); - apply_all_roles( $self, "Koha::SearchEngine::${syspref}::Search" ); -}; -1; --- a/Koha/SearchEngine/SearchRole.pm +++ a/Koha/SearchEngine/SearchRole.pm @@ -1,25 +0,0 @@ -package Koha::SearchEngine::SearchRole; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose::Role; - -requires 'search'; -requires 'dosmth'; - -1; --- a/Koha/SearchEngine/Solr.pm +++ a/Koha/SearchEngine/Solr.pm @@ -1,63 +0,0 @@ -package Koha::SearchEngine::Solr; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; -use Koha::SearchEngine::Config; - -extends 'Koha::SearchEngine', 'Data::SearchEngine::Solr'; - -has '+url' => ( - is => 'ro', - isa => 'Str', -# default => sub { -# C4::Context->preference('SolrAPI'); -# }, - lazy => 1, - builder => '_build_url', - required => 1 -); - -sub _build_url { - my ( $self ) = @_; - $self->config->SolrAPI; -} - -has '+options' => ( - is => 'ro', - isa => 'HashRef', - default => sub { - { - wt => 'json', - fl => '*,score', - fq => 'recordtype:biblio', - facets => 'true' - } - } - -); - -has indexes => ( - is => 'ro', - lazy => 1, - default => sub { -# my $dbh => ...; - }, -); - -1; --- a/Koha/SearchEngine/Solr/Config.pm +++ a/Koha/SearchEngine/Solr/Config.pm @@ -1,132 +0,0 @@ -package Koha::SearchEngine::Solr::Config; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Modern::Perl; -use Moose::Role; -use YAML; - -with 'Koha::SearchEngine::ConfigRole'; - -has index_config => ( - is => 'rw', - lazy => 1, - builder => '_load_index_config_file', -); - -has solr_config => ( - is => 'rw', - lazy => 1, - builder => '_load_solr_config_file', -); - -has index_filename => ( - is => 'rw', - lazy => 1, - default => C4::Context->config("installdir") . qq{/etc/searchengine/solr/indexes.yaml}, -); -has solr_filename => ( - is => 'rw', - lazy => 1, - default => C4::Context->config("installdir") . qq{/etc/searchengine/solr/config.yaml}, -); - -sub _load_index_config_file { - my ( $self, $filename ) = @_; - $self->index_filename( $filename ) if defined $filename; - die "The config index file (" . $self->index_filename . ") for Solr is not exist" if not -e $self->index_filename; - - return YAML::LoadFile($self->index_filename); -} - -sub _load_solr_config_file { - my ( $self ) = @_; - die "The solr config index file (" . $self->solr_filename . ") for Solr is not exist" if not -e $self->solr_filename; - - return YAML::LoadFile($self->solr_filename); -} - -sub set_config_filename { - my ( $self, $filename ) = @_; - $self->index_config( $self->_load_index_config_file( $filename ) ); -} - -sub SolrAPI { - my ( $self ) = @_; - return $self->solr_config->{SolrAPI}; -} -sub indexes { # FIXME Return index list if param not an hashref (string ressource_type) - my ( $self, $indexes ) = @_; - return $self->write( { indexes => $indexes } ) if defined $indexes; - return $self->index_config->{indexes}; -} - -sub index { - my ( $self, $code ) = @_; - my @index = map { ( $_->{code} eq $code ) ? $_ : () } @{$self->index_config->{indexes}}; - return $index[0]; -} - -sub ressource_types { - my ( $self ) = @_; - my $config = $self->index_config; - return $config->{ressource_types}; -} - -sub sortable_indexes { - my ( $self ) = @_; - my @sortable_indexes = map { $_->{sortable} ? $_ : () } @{ $self->index_config->{indexes} }; - return \@sortable_indexes; -} - -sub facetable_indexes { - my ( $self ) = @_; - my @facetable_indexes = map { $_->{facetable} ? $_ : () } @{ $self->index_config->{indexes} }; - return \@facetable_indexes; -} - -sub reload { - my ( $self ) = @_; - $self->index_config( $self->_load_index_config_file ); -} -sub write { - my ( $self, $values ) = @_; - my $r; - while ( my ( $k, $v ) = each %$values ) { - $r->{$k} = $v; - } - - if ( not grep /^ressource_type$/, keys %$values ) { - $r->{ressource_types} = $self->ressource_types; - } - - if ( not grep /^indexes$/, keys %$values ) { - $r->{indexes} = $self->indexes; - } - - eval { - YAML::DumpFile( $self->index_filename, $r ); - }; - if ( $@ ) { - die "Failed to dump the index config into the specified file ($@)"; - } - - $self->reload; -} - -1; --- a/Koha/SearchEngine/Solr/FacetsBuilder.pm +++ a/Koha/SearchEngine/Solr/FacetsBuilder.pm @@ -1,58 +0,0 @@ -package Koha::SearchEngine::Solr::FacetsBuilder; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Modern::Perl; -use Moose::Role; - -with 'Koha::SearchEngine::FacetsBuilderRole'; - -sub build_facets { - my ( $self, $results, $facetable_indexes, $filters ) = @_; - my @facets_loop; - for my $index ( @$facetable_indexes ) { - my $index_name = $index->{type} . '_' . $index->{code}; - my $facets = $results->facets->{'str_' . $index->{code}}; - if ( @$facets > 1 ) { - my @values; - $index =~ m/^([^_]*)_(.*)$/; - for ( my $i = 0 ; $i < scalar(@$facets) ; $i++ ) { - my $value = $facets->[$i++]; - my $count = $facets->[$i]; - utf8::encode($value); - my $lib =$value; - push @values, { - 'lib' => $lib, - 'value' => $value, - 'count' => $count, - 'active' => ( $filters->{$index_name} and scalar( grep /"?\Q$value\E"?/, @{ $filters->{$index_name} } ) ) ? 1 : 0, - }; - } - - push @facets_loop, { - 'indexname' => $index_name, - 'label' => $index->{label}, - 'values' => \@values, - 'size' => scalar(@values), - }; - } - } - return @facets_loop; -} - -1; --- a/Koha/SearchEngine/Solr/Index.pm +++ a/Koha/SearchEngine/Solr/Index.pm @@ -1,126 +0,0 @@ -package Koha::SearchEngine::Solr::Index; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# Copyright 2012 C & P Bibliography Services -# Copyright 2012 PTFS-Europe Ltd. -# -# 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, see . - -use Moose::Role; -with 'Koha::SearchEngine::IndexRole'; - -use Data::SearchEngine::Solr; -use Data::Dump qw(dump); -use List::MoreUtils qw(uniq); - -use Koha::SearchEngine::Solr; -use C4::AuthoritiesMarc; -use C4::Biblio; -use Koha::RecordProcessor; - -has searchengine => ( - is => 'rw', - isa => 'Koha::SearchEngine::Solr', - default => sub { Koha::SearchEngine::Solr->new }, - lazy => 1 -); - -sub optimize { - my ( $self ) = @_; - return $self->searchengine->_solr->optimize; -} - -sub index_record { - my ($self, $recordtype, $recordids) = @_; - - my $indexes = $self->searchengine->config->indexes; - my @records; - - my $recordids_str = ref($recordids) eq 'ARRAY' - ? join " ", @$recordids - : $recordids; - warn "IndexRecord called with $recordtype $recordids_str"; - - for my $id ( @$recordids ) { - my $record; - - $record = GetAuthority( $id ) if $recordtype eq "authority"; - $record = GetMarcBiblio( $id ) if $recordtype eq "biblio"; - - if ($recordtype eq 'biblio' && C4::Context->preference('IncludeSeeFromInSearches')) { - my $normalizer = Koha::RecordProcessor->new( { filters => 'EmbedSeeFromHeadings' } ); - $record = $normalizer->process($record); - } - - next unless ( $record ); - - my $index_values = { - recordid => $id, - recordtype => $recordtype, - }; - - warn "Indexing $recordtype $id"; - - for my $index ( @$indexes ) { - next if $index->{ressource_type} ne $recordtype; - my @values; - eval { - my $mappings = $index->{mappings}; - for my $tag_subf_code ( sort @$mappings ) { - my ( $f, $sf ) = split /\$/, $tag_subf_code; - for my $field ( $record->field( $f ) ) { - if ( $field->is_control_field ) { - push @values, $field->data; - } else { - my @sfvals = $sf eq '*' - ? map { $_->[1] } $field->subfields - : map { $_ } $field->subfield( $sf ); - - for ( @sfvals ) { - $_ = NormalizeDate( $_ ) if $index->{type} eq 'date'; - push @values, $_ if $_; - } - } - } - } - @values = uniq (@values); #Removes duplicates - - $index_values->{$index->{type}."_".$index->{code}} = \@values; - if ( $index->{sortable} ){ - $index_values->{"srt_" . $index->{type} . "_".$index->{code}} = $values[0]; - } - # Add index str for facets if it's not exist - if ( $index->{facetable} and @values > 0 and $index->{type} ne 'str' ) { - $index_values->{"str_" . $index->{code}} = $values[0]; - } - }; - if ( $@ ) { - chomp $@; - warn "Error during indexation : recordid $id, index $index->{code} ( $@ )"; - } - } - - my $solrrecord = Data::SearchEngine::Item->new( - id => "${recordtype}_$id", - score => 1, - values => $index_values, - ); - push @records, $solrrecord; - } - $self->searchengine->add( \@records ); -} - -1; --- a/Koha/SearchEngine/Solr/QueryBuilder.pm +++ a/Koha/SearchEngine/Solr/QueryBuilder.pm @@ -1,163 +0,0 @@ -package Koha::SearchEngine::Solr::QueryBuilder; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Modern::Perl; -use Moose::Role; - -with 'Koha::SearchEngine::QueryBuilderRole'; - -sub build_advanced_query { - my ($class, $indexes, $operands, $operators) = @_; - - my $q = ''; - my $i = 0; - my $index_name; - - @$operands or return "*:*"; #push @$operands, "[* TO *]"; - - # Foreach operands - for my $kw (@$operands){ - $kw =~ s/(\w*\*)/\L$1\E/g; # Lower case on words with right truncation - $kw =~ s/(\s*\w*\?+\w*\s*)/\L$1\E/g; # Lower case on words contain wildcard ? - $kw =~ s/([^\\]):/$1\\:/g; # escape colons if not already escaped - # First element - if ($i == 0){ - if ( (my @x = eval {@$indexes} ) == 0 ){ - # There is no index, then query is in first operand - $q = @$operands[0]; - last; - } - - # Catch index name if it's not 'all_fields' - if ( @$indexes[$i] ne 'all_fields' ) { - $index_name = @$indexes[$i]; - }else{ - $index_name = ''; - } - - # Generate index:operand - $q .= BuildTokenString($index_name, $kw); - $i = $i + 1; - - next; - } - # And others - $index_name = @$indexes[$i] if @$indexes[$i]; - my $operator = defined @$operators[$i-1] ? @$operators[$i-1] : 'AND'; - for ( uc ( $operator ) ) { - when ('OR'){ - $q .= BuildTokenString($index_name, $kw, 'OR'); - } - when ('NOT'){ - $q .= BuildTokenString($index_name, $kw, 'NOT'); - } - default { - $q .= BuildTokenString($index_name, $kw, 'AND'); - } - } - $i = $i + 1; - } - - return $q; - -} - -sub BuildTokenString { - my ($index, $string, $operator) = @_; - my $r; - - if ($index ne 'all_fields' && $index ne ''){ - # Operand can contains an expression in brackets - if ( - $string =~ / / - and not ( $string =~ /^\(.*\)$/ ) - and not $string =~ /\[.*TO.*\]/ ) { - my @dqs; #double-quoted string - while ( $string =~ /"(?:[^"\\]++|\\.)*+"/g ) { - push @dqs, $&; - $string =~ s/\ *\Q$&\E\ *//; # Remove useless space before and after - } - - my @words = defined $string ? split ' ', $string : undef; - my $join = join qq{ AND } , map { - my $value = $_; - if ( $index =~ /^date_/ ) { - #$value = C4::Search::Engine::Solr::buildDateOperand( $value ); TODO - } - ( $value =~ /^"/ and $value ne '""' - and $index ne "emallfields" - and $index =~ /(txt_|ste_)/ ) - ? qq{em$index:$value} - : qq{$index:$value}; - } (@dqs, @words); - $r .= qq{($join)}; - } else { - if ( $index =~ /^date_/ ) { - #$string = C4::Search::Engine::Solr::buildDateOperand( $string ); TODO - } - - $r = "$index:$string"; - } - }else{ - $r = $string; - } - - return " $operator $r" if $operator; - return $r; -} - -sub build_query { - my ($class, $query) = @_; - - return "*:*" if not defined $query; - - # Particular *:* query - if ($query eq '*:*'){ - return $query; - } - - $query =~ s/(\w*\*)/\L$1\E/g; # Lower case on words with right truncation - $query =~ s/(\s*\w*\?+\w*\s*)/\L$1\E/g; # Lower case on words contain wildcard ? - - my @quotes; # Process colons in quotes - while ( $query =~ /'(?:[^'\\]++|\\.)*+'/g ) { - push @quotes, $&; - } - - for ( @quotes ) { - my $replacement = $_; - $replacement =~ s/[^\\]\K:/\\:/g; - $query =~ s/$_/$replacement/; - } - - $query =~ s/ : / \\: /g; # escape colons if " : " - - my $new_query = $query;#C4::Search::Query::splitToken($query); TODO - - $new_query =~ s/all_fields://g; - - # Upper case for operators - $new_query =~ s/ or / OR /g; - $new_query =~ s/ and / AND /g; - $new_query =~ s/ not / NOT /g; - - return $new_query; -} - -1; --- a/Koha/SearchEngine/Solr/Search.pm +++ a/Koha/SearchEngine/Solr/Search.pm @@ -1,128 +0,0 @@ -package Koha::SearchEngine::Solr::Search; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# Copyright 2012 KohaAloha -# -# 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, see . - -use Moose::Role; -with 'Koha::SearchEngine::SearchRole'; - -use Data::Dump qw(dump); -use XML::Simple; - -use Data::SearchEngine::Solr; -use Data::Pagination; -use Data::SearchEngine::Query; -use Koha::SearchEngine::Solr; - -has searchengine => ( - is => 'rw', - isa => 'Koha::SearchEngine::Solr', - default => sub { Koha::SearchEngine::Solr->new }, - lazy => 1 -); - -sub search { - my ( $self, $q, $filters, $params ) = @_; - - $q ||= '*:*'; - $filters ||= {}; - my $page = defined $params->{page} ? $params->{page} : 1; - my $count = defined $params->{count} ? $params->{count} : 999999999; - my $sort = defined $params->{sort} ? $params->{sort} : 'score desc'; - my $facets = defined $params->{facets} ? $params->{facets} : 0; - - # Construct fl from $params->{fl} - # If "recordid" or "id" not exist, we push them - my $fl = join ",", - defined $params->{fl} - ? ( - @{$params->{fl}}, - grep ( /^recordid$/, @{$params->{fl}} ) ? () : "recordid", - grep ( /^id$/, @{$params->{fl}} ) ? () : "id" - ) - : ( "recordid", "id" ); - - my $recordtype; - $recordtype = ref($filters->{recordtype}) eq 'ARRAY' - ? $filters->{recordtype}[0] - : $filters->{recordtype} - if defined $filters && defined $filters->{recordtype}; - - if ( $facets ) { - $self->searchengine->options->{"facet"} = 'true'; - $self->searchengine->options->{"facet.mincount"} = 1; - $self->searchengine->options->{"facet.limit"} = 10; # TODO create a new systempreference C4::Context->preference("numFacetsDisplay") - my @facetable_indexes = map { 'str_' . $_->{code} } @{$self->searchengine->config->facetable_indexes}; - $self->searchengine->options->{"facet.field"} = \@facetable_indexes; - } - $self->searchengine->options->{sort} = $sort; - $self->searchengine->options->{fl} = $fl; - - # Construct filters - $self->searchengine->options->{fq} = [ - map { - my $idx = $_; - ref($filters->{$idx}) eq 'ARRAY' - ? - '(' - . join( ' AND ', - map { - my $filter_str = $_; - utf8::decode($filter_str); - my $quotes_existed = ( $filter_str =~ m/^".*"$/ ); - $filter_str =~ s/^"(.*)"$/$1/; #remove quote around value if exist - $filter_str =~ s/[^\\]\K"/\\"/g; - $filter_str = qq{"$filter_str"} # Add quote around value if not exist - if not $filter_str =~ /^".*"$/ - and $quotes_existed; - qq{$idx:$filter_str}; - } @{ $filters->{$idx} } ) - . ')' - : "$idx:$filters->{$idx}"; - } keys %$filters - ]; - - my $sq = Data::SearchEngine::Query->new( - page => $page, - count => $count, - query => $q, - ); - - # Get results - my $results = eval { $self->searchengine->search( $sq ) }; - - # Get error if exists - if ( $@ ) { - my $err = $@; - - $err =~ s#^[^\n]*\n##; # Delete first line - if ( $err =~ "400 URL must be absolute" ) { - $err = "Your system preference 'SolrAPI' is not set correctly"; - } - elsif ( not $err =~ 'Connection refused' ) { - my $document = XMLin( $err ); - $err = "$$document{body}{h2} : $$document{body}{pre}"; - } - $results->{error} = $err; - } - return $results; -} - -sub dosmth {'bou' } - -1; --- a/Koha/SearchEngine/Zebra.pm +++ a/Koha/SearchEngine/Zebra.pm @@ -1,32 +0,0 @@ -package Koha::SearchEngine::Zebra; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose; - -extends 'Data::SearchEngine::Zebra'; - -# the configuration file is retrieved from KOHA_CONF by default, provide it from thereĀ² -has '+conf_file' => ( - is => 'ro', - isa => 'Str', - default => $ENV{KOHA_CONF}, - required => 1 -); - -1; --- a/Koha/SearchEngine/Zebra/QueryBuilder.pm +++ a/Koha/SearchEngine/Zebra/QueryBuilder.pm @@ -1,31 +0,0 @@ -package Koha::SearchEngine::Zebra::QueryBuilder; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Modern::Perl; -use Moose::Role; -use C4::Search; - -with 'Koha::SearchEngine::QueryBuilderRole'; - -sub build_query { - shift; - C4::Search::buildQuery @_; -} - -1; --- a/Koha/SearchEngine/Zebra/Search.pm +++ a/Koha/SearchEngine/Zebra/Search.pm @@ -1,58 +0,0 @@ -package Koha::SearchEngine::Zebra::Search; - -# This file is part of Koha. -# -# Copyright 2012 BibLibre -# -# 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, see . - -use Moose::Role; -with 'Koha::SearchEngine::SearchRole'; - -use Data::SearchEngine::Zebra; -use Data::SearchEngine::Query; -use Koha::SearchEngine::Zebra; -use Data::Dump qw(dump); - -has searchengine => ( - is => 'rw', - isa => 'Koha::SearchEngine::Zebra', - default => sub { Koha::SearchEngine::Zebra->new }, - lazy => 1 -); - -sub search { - my ($self,$query_string) = @_; - - my $query = Data::SearchEngine::Query->new( - count => 10, - page => 1, - query => $query_string, - ); - - warn "search for $query_string"; - - my $results = $self->searchengine->search($query); - - foreach my $item (@{ $results->items }) { - my $title = $item->get_value('ste_title'); - #utf8::encode($title); - print "$title\n"; - warn dump $title; - } -} - -sub dosmth {'bou' } - -1; --- a/admin/admin-home.pl +++ a/admin/admin-home.pl @@ -34,6 +34,4 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); -$template->param( SearchEngine => C4::Context->preference('SearchEngine') ); - output_html_with_http_headers $query, $cookie, $template->output; --- a/admin/searchengine/solr/indexes.pl +++ a/admin/searchengine/solr/indexes.pl @@ -1,103 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2012 BibLibre SARL -# -# 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 2 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 CGI; -use C4::Koha; -use C4::Output; -use C4::Auth; -use Koha::SearchEngine; - -my $input = new CGI; -my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => 'admin/searchengine/solr/indexes.tt', - query => $input, - type => 'intranet', -# authnotrequired => 0, -# flagsrequired => { reserveforothers => "place_holds" }, #TODO - } -); - -my $ressource_type = $input->param('ressource_type') || 'biblio'; -my $se = Koha::SearchEngine->new; -my $se_config = $se->config; - -my $indexes; -if ( $input->param('op') and $input->param('op') eq 'edit' ) { - my @code = $input->param('code'); - my @label = $input->param('label'); - my @type = $input->param('type'); - my @sortable = $input->param('sortable'); - my @facetable = $input->param('facetable'); - my @mandatory = $input->param('mandatory'); - my @ressource_type = $input->param('ressource_type'); - my @mappings = $input->param('mappings'); - my @indexes; - my @errors; - for ( 0 .. @code-1 ) { - my $icode = $code[$_]; - my @current_mappings = split /\r\n/, $mappings[$_]; - if ( not @current_mappings ) { - @current_mappings = split /\n/, $mappings[$_]; - } - if ( not @current_mappings ) { - push @errors, { type => 'no_mapping', value => $icode}; - } - - push @indexes, { - code => $icode, - label => $label[$_], - type => $type[$_], - sortable => scalar(grep(/^$icode$/, @sortable)), - facetable => scalar(grep(/^$icode$/, @facetable)), - mandatory => $mandatory[$_] eq '1' ? '1' : '0', - ressource_type => $ressource_type[$_], - mappings => \@current_mappings, - }; - for my $m ( @current_mappings ) { - push @errors, {type => 'malformed_mapping', value => $m} - if not $m =~ /^\d(\d|\*|\.){2}\$.$/; - } - } - $indexes = \@indexes if @errors; - $template->param( errors => \@errors ); - - $se_config->indexes(\@indexes) if not @errors; -} - -my $ressource_types = $se_config->ressource_types; -$indexes //= $se_config->indexes; - -my $indexloop; -for my $rt ( @$ressource_types ) { - my @indexes = map { - $_->{ressource_type} eq $rt ? $_ : (); - } @$indexes; - push @$indexloop, { - ressource_type => $rt, - indexes => \@indexes, - } -} - -$template->param( - indexloop => $indexloop, -); - -output_html_with_http_headers $input, $cookie, $template->output; --- a/debian/rules +++ a/debian/rules @@ -20,9 +20,6 @@ override_dh_auto_install: rm -r $(TMP)/var/run rm -r $(TMP)/var/lock rm $(TMP)/var/log/koha/README - rm $(TMP)/etc/koha/searchengine/solr/config.yaml - rm $(TMP)/etc/koha/searchengine/solr/indexes.yaml - rm $(TMP)/etc/koha/solr/indexes.yaml rm -r \ $(TMP)/usr/share/koha/intranet/htdocs/intranet-tmpl/lib/tiny_mce ln -s /usr/share/tinymce/www \ --- a/etc/searchengine/solr/config.yaml +++ a/etc/searchengine/solr/config.yaml @@ -1, +0,0 @@ -SolrAPI: 'http://localhost:8983/solr/solr' --- a/etc/searchengine/solr/indexes.yaml +++ a/etc/searchengine/solr/indexes.yaml @@ -1,45 +0,0 @@ ---- -indexes: - - code: title - facetable: 1 - label: Title - mandatory: 1 - mappings: - - 200$a - - 210$a - - 4..$t - ressource_type: biblio - sortable: 1 - type: ste - - code: author - facetable: 1 - label: Author - mandatory: 0 - mappings: - - 700$* - - 710$* - ressource_type: biblio - sortable: 1 - type: str - - code: subject - facetable: 0 - label: Subject - mandatory: 0 - mappings: - - 600$a - - 601$a - ressource_type: biblio - sortable: 0 - type: str - - code: biblionumber - facetable: 0 - label: Biblionumber - mandatory: 1 - mappings: - - 001$@ - ressource_type: biblio - sortable: 0 - type: int -ressource_types: - - biblio - - authority --- a/etc/searchengine/solr/indexes.yaml.bak +++ a/etc/searchengine/solr/indexes.yaml.bak @@ -1,33 +0,0 @@ -ressource_types: - - biblio - - authority - -indexes: - - code: title - label: Title - type: ste - ressource_type: biblio - sortable: 1 - mandatory: 1 - mappings: - - 200$a - - 210$a - - 4..$t - - code: author - label: Author - type: str - ressource_type: biblio - sortable: 1 - mandatory: 0 - mappings: - - 700$* - - 710$* - - code: subject - label: Subject - type: str - ressource_type: biblio - sortable: 0 - mandatory: 0 - mappings: - - 600$a - - 601$a --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -346,7 +346,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'), ('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded