diff --git a/C4/Biblio.pm b/C4/Biblio.pm index f2e7014db6..ec4c71ebed 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -657,7 +657,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. diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm index ad1f5a6217..532a16a452 100644 --- a/C4/Installer/PerlDependencies.pm +++ b/C4/Installer/PerlDependencies.pm @@ -552,41 +552,6 @@ 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', diff --git a/Koha/SearchEngine.pm b/Koha/SearchEngine.pm deleted file mode 100644 index 6cfc46197a..0000000000 --- a/Koha/SearchEngine.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Config.pm b/Koha/SearchEngine/Config.pm deleted file mode 100644 index 497e448e51..0000000000 --- a/Koha/SearchEngine/Config.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/ConfigRole.pm b/Koha/SearchEngine/ConfigRole.pm deleted file mode 100644 index e75a62db3e..0000000000 --- a/Koha/SearchEngine/ConfigRole.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/FacetsBuilder.pm b/Koha/SearchEngine/FacetsBuilder.pm deleted file mode 100644 index a43b30dd12..0000000000 --- a/Koha/SearchEngine/FacetsBuilder.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/FacetsBuilderRole.pm b/Koha/SearchEngine/FacetsBuilderRole.pm deleted file mode 100644 index 3a8b21c650..0000000000 --- a/Koha/SearchEngine/FacetsBuilderRole.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Index.pm b/Koha/SearchEngine/Index.pm deleted file mode 100644 index 59fd4b68a6..0000000000 --- a/Koha/SearchEngine/Index.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/IndexRole.pm b/Koha/SearchEngine/IndexRole.pm deleted file mode 100644 index d495618d58..0000000000 --- a/Koha/SearchEngine/IndexRole.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/QueryBuilder.pm b/Koha/SearchEngine/QueryBuilder.pm deleted file mode 100644 index 68973fc4f9..0000000000 --- a/Koha/SearchEngine/QueryBuilder.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/QueryBuilderRole.pm b/Koha/SearchEngine/QueryBuilderRole.pm deleted file mode 100644 index 3c1c778b22..0000000000 --- a/Koha/SearchEngine/QueryBuilderRole.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Search.pm b/Koha/SearchEngine/Search.pm deleted file mode 100644 index 1a57887242..0000000000 --- a/Koha/SearchEngine/Search.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/SearchRole.pm b/Koha/SearchEngine/SearchRole.pm deleted file mode 100644 index bd15425b4f..0000000000 --- a/Koha/SearchEngine/SearchRole.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Solr.pm b/Koha/SearchEngine/Solr.pm deleted file mode 100644 index ecc9308b4c..0000000000 --- a/Koha/SearchEngine/Solr.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Solr/Config.pm b/Koha/SearchEngine/Solr/Config.pm deleted file mode 100644 index 001169f0b1..0000000000 --- a/Koha/SearchEngine/Solr/Config.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Solr/FacetsBuilder.pm b/Koha/SearchEngine/Solr/FacetsBuilder.pm deleted file mode 100644 index 672072db94..0000000000 --- a/Koha/SearchEngine/Solr/FacetsBuilder.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Solr/Index.pm b/Koha/SearchEngine/Solr/Index.pm deleted file mode 100644 index f56dcfa746..0000000000 --- a/Koha/SearchEngine/Solr/Index.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Solr/QueryBuilder.pm b/Koha/SearchEngine/Solr/QueryBuilder.pm deleted file mode 100644 index ba5547f682..0000000000 --- a/Koha/SearchEngine/Solr/QueryBuilder.pm +++ /dev/null @@ -1,159 +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'; - if ( uc ( $operator ) eq 'OR' ) { - $q .= BuildTokenString($index_name, $kw, 'OR'); - } elsif ( uc ( $operator ) eq 'NOT' ) { - $q .= BuildTokenString($index_name, $kw, 'NOT'); - } else { - $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; diff --git a/Koha/SearchEngine/Solr/Search.pm b/Koha/SearchEngine/Solr/Search.pm deleted file mode 100644 index 603c83368e..0000000000 --- a/Koha/SearchEngine/Solr/Search.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Zebra.pm b/Koha/SearchEngine/Zebra.pm deleted file mode 100644 index ffe18b888a..0000000000 --- a/Koha/SearchEngine/Zebra.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Zebra/QueryBuilder.pm b/Koha/SearchEngine/Zebra/QueryBuilder.pm deleted file mode 100644 index 09a6d93db2..0000000000 --- a/Koha/SearchEngine/Zebra/QueryBuilder.pm +++ /dev/null @@ -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; diff --git a/Koha/SearchEngine/Zebra/Search.pm b/Koha/SearchEngine/Zebra/Search.pm deleted file mode 100644 index 3b736dfde5..0000000000 --- a/Koha/SearchEngine/Zebra/Search.pm +++ /dev/null @@ -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; diff --git a/admin/admin-home.pl b/admin/admin-home.pl index 23a78388cb..b431b49632 100755 --- a/admin/admin-home.pl +++ b/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; diff --git a/admin/searchengine/solr/indexes.pl b/admin/searchengine/solr/indexes.pl deleted file mode 100755 index 39a5276984..0000000000 --- a/admin/searchengine/solr/indexes.pl +++ /dev/null @@ -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; diff --git a/debian/rules b/debian/rules index b00b9b8a3a..dc6ce6a543 100755 --- a/debian/rules +++ b/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 \ diff --git a/etc/searchengine/solr/config.yaml b/etc/searchengine/solr/config.yaml deleted file mode 100644 index 26c219b71f..0000000000 --- a/etc/searchengine/solr/config.yaml +++ /dev/null @@ -1 +0,0 @@ -SolrAPI: 'http://localhost:8983/solr/solr' diff --git a/etc/searchengine/solr/indexes.yaml b/etc/searchengine/solr/indexes.yaml deleted file mode 100644 index ca598f8ea4..0000000000 --- a/etc/searchengine/solr/indexes.yaml +++ /dev/null @@ -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 diff --git a/etc/searchengine/solr/indexes.yaml.bak b/etc/searchengine/solr/indexes.yaml.bak deleted file mode 100644 index b369160e99..0000000000 --- a/etc/searchengine/solr/indexes.yaml.bak +++ /dev/null @@ -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 diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index b06b1635fb..b845d53371 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -348,7 +348,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