View | Details | Raw Unified | Return to bug 17372
Collapse All | Expand All

(-)a/C4/Biblio.pm (-2 / +2 lines)
Lines 2974-2981 sub ModZebra { Link Here
2974
    if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) {
2974
    if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) {
2975
2975
2976
        # TODO abstract to a standard API that'll work for whatever
2976
        # TODO abstract to a standard API that'll work for whatever
2977
        require Koha::ElasticSearch::Indexer;
2977
        require Koha::SearchEngine::Elasticsearch::Indexer;
2978
        my $indexer = Koha::ElasticSearch::Indexer->new(
2978
        my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new(
2979
            {
2979
            {
2980
                index => $server eq 'biblioserver'
2980
                index => $server eq 'biblioserver'
2981
                ? $Koha::SearchEngine::BIBLIOS_INDEX
2981
                ? $Koha::SearchEngine::BIBLIOS_INDEX
(-)a/Koha/ElasticSearch.pm (-2 / +4 lines)
Lines 1-4 Link Here
1
package Koha::ElasticSearch;
1
package Koha::SearchEngine::Elasticsearch;
2
2
3
# Copyright 2015 Catalyst IT
3
# Copyright 2015 Catalyst IT
4
#
4
#
Lines 42-48 Readonly our $AUTHORITIES_INDEX => 'authorities'; Link Here
42
42
43
=head1 NAME
43
=head1 NAME
44
44
45
Koha::ElasticSearch - Base module for things using elasticsearch
45
Koha::SearchEngine::Elasticsearch - Base module for things using elasticsearch
46
46
47
=head1 ACCESSORS
47
=head1 ACCESSORS
48
48
Lines 466-471 __END__ Link Here
466
466
467
=item Robin Sheat C<< <robin@catalyst.net.nz> >>
467
=item Robin Sheat C<< <robin@catalyst.net.nz> >>
468
468
469
=item Jonathan Druart C<< <jonathan.druart@bugs.koha-community.org> >>
470
469
=back
471
=back
470
472
471
=cut
473
=cut
(-)a/Koha/ElasticSearch/Indexer.pm (-5 / +5 lines)
Lines 1-4 Link Here
1
package Koha::ElasticSearch::Indexer;
1
package Koha::SearchEngine::Elasticsearch::Indexer;
2
2
3
# Copyright 2013 Catalyst IT
3
# Copyright 2013 Catalyst IT
4
#
4
#
Lines 19-40 package Koha::ElasticSearch::Indexer; Link Here
19
19
20
use Carp;
20
use Carp;
21
use Modern::Perl;
21
use Modern::Perl;
22
use base qw(Koha::ElasticSearch);
22
use base qw(Koha::SearchEngine::Elasticsearch);
23
use Data::Dumper;
23
use Data::Dumper;
24
24
25
# For now just marc, but we can do anything here really
25
# For now just marc, but we can do anything here really
26
use Catmandu::Importer::MARC;
26
use Catmandu::Importer::MARC;
27
use Catmandu::Store::ElasticSearch;
27
use Catmandu::Store::ElasticSearch;
28
28
29
Koha::ElasticSearch::Indexer->mk_accessors(qw( store ));
29
Koha::SearchEngine::Elasticsearch::Indexer->mk_accessors(qw( store ));
30
30
31
=head1 NAME
31
=head1 NAME
32
32
33
Koha::ElasticSearch::Indexer - handles adding new records to the index
33
Koha::SearchEngine::Elasticsearch::Indexer - handles adding new records to the index
34
34
35
=head1 SYNOPSIS
35
=head1 SYNOPSIS
36
36
37
    my $indexer = Koha::ElasticSearch::Indexer->new(
37
    my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new(
38
        { index => Koha::SearchEngine::BIBLIOS_INDEX } );
38
        { index => Koha::SearchEngine::BIBLIOS_INDEX } );
39
    $indexer->drop_index();
39
    $indexer->drop_index();
40
    $indexer->update_index(\@biblionumbers, \@records);
40
    $indexer->update_index(\@biblionumbers, \@records);
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-2 / +2 lines)
Lines 39-45 provides something that can be given to elasticsearch to get answers. Link Here
39
39
40
=cut
40
=cut
41
41
42
use base qw(Koha::ElasticSearch);
42
use base qw(Koha::SearchEngine::Elasticsearch);
43
use Carp;
43
use Carp;
44
use JSON;
44
use JSON;
45
use List::MoreUtils qw/ each_array /;
45
use List::MoreUtils qw/ each_array /;
Lines 143-149 sub build_browse_query { Link Here
143
143
144
    return { query => '*' } if !defined $query;
144
    return { query => '*' } if !defined $query;
145
145
146
    # TODO this should come from Koha::Elasticsearch
146
    # TODO this should come from Koha::SearchEngine::Elasticsearch
147
    my %field_whitelist = (
147
    my %field_whitelist = (
148
        title  => 1,
148
        title  => 1,
149
        author => 1,
149
        author => 1,
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-3 / +3 lines)
Lines 19-30 package Koha::SearchEngine::Elasticsearch::Search; Link Here
19
19
20
=head1 NAME
20
=head1 NAME
21
21
22
Koha::SearchEngine::ElasticSearch::Search - search functions for Elasticsearch
22
Koha::SearchEngine::Elasticsearch::Search - search functions for Elasticsearch
23
23
24
=head1 SYNOPSIS
24
=head1 SYNOPSIS
25
25
26
    my $searcher =
26
    my $searcher =
27
      Koha::SearchEngine::ElasticSearch::Search->new( { index => $index } );
27
      Koha::SearchEngine::Elasticsearch::Search->new( { index => $index } );
28
    my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new(
28
    my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new(
29
        { index => $index } );
29
        { index => $index } );
30
    my $query = $builder->build_query('perl');
30
    my $query = $builder->build_query('perl');
Lines 40-46 Koha::SearchEngine::ElasticSearch::Search - search functions for Elasticsearch Link Here
40
40
41
use Modern::Perl;
41
use Modern::Perl;
42
42
43
use base qw(Koha::ElasticSearch);
43
use base qw(Koha::SearchEngine::Elasticsearch);
44
use C4::Context;
44
use C4::Context;
45
use Koha::ItemTypes;
45
use Koha::ItemTypes;
46
use Koha::AuthorisedValues;
46
use Koha::AuthorisedValues;
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +2 lines)
Lines 12267-12273 $DBversion = "3.23.00.050"; Link Here
12267
if ( CheckVersion($DBversion) ) {
12267
if ( CheckVersion($DBversion) ) {
12268
    use Koha::SearchMarcMaps;
12268
    use Koha::SearchMarcMaps;
12269
    use Koha::SearchFields;
12269
    use Koha::SearchFields;
12270
    use Koha::ElasticSearch;
12270
    use Koha::SearchEngine::Elasticsearch;
12271
12271
12272
    $dbh->do(q|INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
12272
    $dbh->do(q|INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
12273
                    VALUES('SearchEngine','Zebra','Choose Search Engine','','Choice')|);
12273
                    VALUES('SearchEngine','Zebra','Choose Search Engine','','Choice')|);
Lines 12330-12336 $dbh->do(q| Link Here
12330
        |);
12330
        |);
12331
12331
12332
        # Insert default mappings
12332
        # Insert default mappings
12333
        Koha::ElasticSearch->reset_elasticsearch_meppings;
12333
        Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings;
12334
12334
12335
print "Upgrade to $DBversion done (Bug 12478 - Elasticsearch support for Koha)\n";
12335
print "Upgrade to $DBversion done (Bug 12478 - Elasticsearch support for Koha)\n";
12336
    SetVersion($DBversion);
12336
    SetVersion($DBversion);
(-)a/installer/install.pl (-2 / +2 lines)
Lines 209-216 elsif ( $step && $step == 3 ) { Link Here
209
            "fwklanguage" => $fwk_language,
209
            "fwklanguage" => $fwk_language,
210
            "list"        => $list
210
            "list"        => $list
211
        );
211
        );
212
        use Koha::ElasticSearch;
212
        use Koha::SearchEngine::Elasticsearch;
213
        Koha::ElasticSearch->reset_elasticsearch_mappings;
213
        Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings;
214
        $template->param( "$op" => 1 );
214
        $template->param( "$op" => 1 );
215
    }
215
    }
216
    elsif ( $op && $op eq 'selectframeworks' ) {
216
    elsif ( $op && $op eq 'selectframeworks' ) {
(-)a/misc/search_tools/rebuild_elastic_search.pl (-4 / +4 lines)
Lines 86-92 use Getopt::Long; Link Here
86
use C4::Context;
86
use C4::Context;
87
use Koha::MetadataRecord::Authority;
87
use Koha::MetadataRecord::Authority;
88
use Koha::BiblioUtils;
88
use Koha::BiblioUtils;
89
use Koha::ElasticSearch::Indexer;
89
use Koha::SearchEngine::Elasticsearch::Indexer;
90
use MARC::Field;
90
use MARC::Field;
91
use MARC::Record;
91
use MARC::Record;
92
use Modern::Perl;
92
use Modern::Perl;
Lines 136-142 if ($index_biblios) { Link Here
136
            $records->next();
136
            $records->next();
137
        }
137
        }
138
    }
138
    }
139
    do_reindex($next, $Koha::ElasticSearch::BIBLIOS_INDEX);
139
    do_reindex($next, $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX);
140
}
140
}
141
if ($index_authorities) {
141
if ($index_authorities) {
142
    _log(1, "Indexing authorities\n");
142
    _log(1, "Indexing authorities\n");
Lines 153-165 if ($index_authorities) { Link Here
153
            $records->next();
153
            $records->next();
154
        }
154
        }
155
    }
155
    }
156
    do_reindex($next, $Koha::ElasticSearch::AUTHORITIES_INDEX);
156
    do_reindex($next, $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
157
}
157
}
158
158
159
sub do_reindex {
159
sub do_reindex {
160
    my ( $next, $index_name ) = @_;
160
    my ( $next, $index_name ) = @_;
161
161
162
    my $indexer = Koha::ElasticSearch::Indexer->new( { index => $index_name } );
162
    my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( { index => $index_name } );
163
    if ($delete) {
163
    if ($delete) {
164
164
165
        # We know it's safe to not recreate the indexer because update_index
165
        # We know it's safe to not recreate the indexer because update_index
(-)a/t/00-load.t (-1 / +1 lines)
Lines 82-88 sub is_testable { Link Here
82
        @needed_module_names =
82
        @needed_module_names =
83
          ( 'SOAP::Lite', 'Crypt::GCrypt', 'Digest::SHA', 'Convert::BaseN' );
83
          ( 'SOAP::Lite', 'Crypt::GCrypt', 'Digest::SHA', 'Convert::BaseN' );
84
    }
84
    }
85
    elsif ( $module_name =~ /Koha::ElasticSearch::Indexer/xsm ) {
85
    elsif ( $module_name =~ /Koha::SearchEngine::Elasticsearch::Indexer/xsm ) {
86
        @needed_module_names =
86
        @needed_module_names =
87
          ( 'Catmandu::Importer::MARC', 'Catmandu::Store::ElasticSearch' );
87
          ( 'Catmandu::Importer::MARC', 'Catmandu::Store::ElasticSearch' );
88
    }
88
    }
(-)a/t/db_dependent/Koha_ElasticSearch.t (-1 / +1 lines)
Lines 20-23 use warnings; Link Here
20
20
21
use Test::More tests => 1;                      # last test to print
21
use Test::More tests => 1;                      # last test to print
22
22
23
use_ok('Koha::ElasticSearch');
23
use_ok('Koha::Search::Engine::Elasticsearch');
(-)a/t/db_dependent/Koha_ElasticSearch_Indexer.t (-2 / +2 lines)
Lines 21-31 use Test::More tests => 5; Link Here
21
21
22
use MARC::Record;
22
use MARC::Record;
23
23
24
use_ok('Koha::ElasticSearch::Indexer');
24
use_ok('Koha::SearchEngine::Elasticsearch::Indexer');
25
25
26
my $indexer;
26
my $indexer;
27
ok(
27
ok(
28
    $indexer = Koha::ElasticSearch::Indexer->new({ 'index' => 'biblio' }),
28
    $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblio' }),
29
    'Creating new indexer object'
29
    'Creating new indexer object'
30
);
30
);
31
31
(-)a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t (-2 / +1 lines)
Lines 29-35 ok( Link Here
29
    my $searcher = Koha::SearchEngine::Elasticsearch::Search->new(
29
    my $searcher = Koha::SearchEngine::Elasticsearch::Search->new(
30
        { 'nodes' => ['localhost:9200'], 'index' => 'mydb' }
30
        { 'nodes' => ['localhost:9200'], 'index' => 'mydb' }
31
    ),
31
    ),
32
    'Creating a Koha::ElasticSearch::Search object'
32
    'Creating a Koha::SearchEngine::Elasticsearch::Search object'
33
);
33
);
34
34
35
is( $searcher->index, 'mydb', 'Testing basic accessor' );
35
is( $searcher->index, 'mydb', 'Testing basic accessor' );
36
- 

Return to bug 17372