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

(-)a/admin/searchengine/elasticsearch/mappings.pl (-6 / +18 lines)
Lines 22-27 use C4::Output; Link Here
22
use C4::Auth;
22
use C4::Auth;
23
23
24
use Koha::SearchEngine::Elasticsearch;
24
use Koha::SearchEngine::Elasticsearch;
25
use Koha::SearchEngine::Elasticsearch::Indexer;
25
use Koha::SearchMarcMaps;
26
use Koha::SearchMarcMaps;
26
use Koha::SearchFields;
27
use Koha::SearchFields;
27
28
Lines 37-42 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
37
38
38
my $index = $input->param('index') || 'biblios';
39
my $index = $input->param('index') || 'biblios';
39
my $op    = $input->param('op')    || 'list';
40
my $op    = $input->param('op')    || 'list';
41
my $action = $input->param('action') || '';
40
my @messages;
42
my @messages;
41
43
42
my $database = Koha::Database->new();
44
my $database = Koha::Database->new();
Lines 97-108 if ( $op eq 'edit' ) { Link Here
97
        $schema->storage->txn_commit;
99
        $schema->storage->txn_commit;
98
    }
100
    }
99
}
101
}
100
elsif( $op eq 'reset' ) {
102
elsif( $op eq 'admin') {
101
    # TODO Move this feature to the interface
103
    if( $input->param('admin_password') eq C4::Context->config('elasticsearch_admin_password') ){
102
    my $sure = $input->param('i_know_what_i_am_doing');
104
        if ( $action eq 'reset' ) {
103
    if ( $sure ) {
105
            Koha::SearchMarcMaps->search->delete;
104
        Koha::SearchMarcMaps->search->delete;
106
            Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings;
105
        Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings;
107
            $template->param( mappings_reset => 1 );
108
        }
109
        elsif ( $action eq 'reindex' ) {
110
            my $reindex_bibs = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' })->do_reindex( undef, undef, 0, [] );
111
            my $reindex_auths = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'authorities' })->do_reindex( undef, undef, 0, [] );
112
            $template->param( reindex_launched => 1 );
113
        }
114
    }
115
    else {
116
        $template->param( admin_badpassword => 1 );
106
    }
117
    }
107
}
118
}
108
119
Lines 139-144 $template->param( Link Here
139
    indexes           => \@indexes,
150
    indexes           => \@indexes,
140
    all_search_fields => \@all_search_fields,
151
    all_search_fields => \@all_search_fields,
141
    messages          => \@messages,
152
    messages          => \@messages,
153
    show_admin_options => C4::Context->config('elasticsearch_admin_password') ? 1 : 0,
142
);
154
);
143
155
144
output_html_with_http_headers $input, $cookie, $template->output;
156
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/debian/scripts/koha-create (+3 lines)
Lines 106-111 generate_config_file() { Link Here
106
        -e "s/__START_AUTHORITIES_RETRIEVAL_INFO__/`echo $START_AUTHORITIES_RETRIEVAL_INFO`/g" \
106
        -e "s/__START_AUTHORITIES_RETRIEVAL_INFO__/`echo $START_AUTHORITIES_RETRIEVAL_INFO`/g" \
107
        -e "s/__END_AUTHORITIES_RETRIEVAL_INFO__/`echo $END_AUTHORITIES_RETRIEVAL_INFO`/g" \
107
        -e "s/__END_AUTHORITIES_RETRIEVAL_INFO__/`echo $END_AUTHORITIES_RETRIEVAL_INFO`/g" \
108
        -e "s/__API_SECRET__/$API_SECRET/g" \
108
        -e "s/__API_SECRET__/$API_SECRET/g" \
109
        -e "s/__ES_ADMIN_PASSWORD__/$ES_ADMIN_PASSWORD/g" \
109
        -e "s/__DB_NAME__/$mysqldb/g" \
110
        -e "s/__DB_NAME__/$mysqldb/g" \
110
        -e "s/__DB_HOST__/$mysqlhost/g" \
111
        -e "s/__DB_HOST__/$mysqlhost/g" \
111
        -e "s/__DB_USER__/$mysqluser/g" \
112
        -e "s/__DB_USER__/$mysqluser/g" \
Lines 406-411 UPLOAD_DIR="uploads" Link Here
406
UPLOAD_PATH=""
407
UPLOAD_PATH=""
407
# Generate a randomizaed API secret
408
# Generate a randomizaed API secret
408
API_SECRET="$(pwgen -s 64 1)"
409
API_SECRET="$(pwgen -s 64 1)"
410
# Generate a randomizaed ES Admin Password secret
411
ES_ADMIN_PASSWORD="$(pwgen -s 16 1)"
409
# SRU server variables
412
# SRU server variables
410
ENABLE_SRU="no"
413
ENABLE_SRU="no"
411
SRU_SERVER_PORT=""
414
SRU_SERVER_PORT=""
(-)a/debian/templates/koha-conf-site.xml.in (+4 lines)
Lines 326-331 __END_SRU_PUBLICSERVER__ Link Here
326
     <server>localhost:9200</server>
326
     <server>localhost:9200</server>
327
     <index_name>koha___KOHASITE__</index_name>
327
     <index_name>koha___KOHASITE__</index_name>
328
 </elasticsearch>
328
 </elasticsearch>
329
 <!-- Uncomment the following line to allow access to reindexing tools via Search
330
 Configuration page in staff interface
331
 <elasticsearch_admin_password>__ES_ADMIN_PASSWORD__</elasticsearch_admin_password>
332
 -->
329
333
330
</config>
334
</config>
331
</yazgfs>
335
</yazgfs>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (-2 / +20 lines)
Lines 1-3 Link Here
1
[% USE Koha %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Administration &rsaquo; Elastic Search mappings</title>
3
<title>Koha &rsaquo; Administration &rsaquo; Elastic Search mappings</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 88-94 a.add, a.delete { Link Here
88
89
89
    <h1>Search engine configuration</h1>
90
    <h1>Search engine configuration</h1>
90
    <div class="warning">
91
    <div class="warning">
91
        Warning: Any modification in these configurations will need a total reindexation to be fully taken into account !
92
        Warning: Any modification in these configurations will need a total reindexation to be fully taken into account ! <br/>
93
        [% IF (show_admin_options) %]
94
            [% IF (admin_badpassword) %]<p>The password you entered was incorrect!</p>[% END %]
95
            [% IF (reindex_launched) %]<p>A rebuild has been completed<p/>
96
            [% ELSIF (mappings_reset) %]<p>Mappings have been reset<p/>
97
            [% ELSE %]
98
                <form method="post">
99
                    <label for="admin_password">Enter the Elasticsearch admin password and select action</labe;>
100
                    <input type="text" name="admin_password" value="" id="admin_password"/>
101
                    <input type="hidden" name="op" value="admin" />
102
                    <select name="action">
103
                       <option value="reindex">Launch reindex</option>
104
                       <option value="reset">Reset mappings</option>
105
                    </select>
106
                    <input type="submit" value="Submit" />
107
                </form>
108
            [% END %]
109
        [% END %]
110
92
    </div>
111
    </div>
93
    [% IF errors %]
112
    [% IF errors %]
94
        <div class="error">
113
        <div class="error">
95
- 

Return to bug 18950