Bugzilla – Attachment 102354 Details for
Bug 23137
Add a command line tool to reset elasticsearch mappings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23137: Add reset option to rebuild_elasticsearch.pl
Bug-23137-Add-reset-option-to-rebuildelasticsearch.patch (text/plain), 3.23 KB, created by
Andrew Fuerste-Henry
on 2020-04-03 12:57:34 UTC
(
hide
)
Description:
Bug 23137: Add reset option to rebuild_elasticsearch.pl
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2020-04-03 12:57:34 UTC
Size:
3.23 KB
patch
obsolete
>From f51835e76d215a6f7e8c3b4e198faf90742970e8 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 19 Mar 2020 16:30:29 +0000 >Subject: [PATCH] Bug 23137: Add reset option to rebuild_elasticsearch.pl > >Setup: >1 - Be using Elasticsearch >2 - Reload mappings from the db > Admin->Search configuration > Reset Mappings >3 - Reindex ES and confirm searching is working > >To test: >1 - Apply patch >2 - Alter your mappings file for elastic (just change a description for a field) >3 - perl misc/search_tools/rebuild_elasticsearch.pl -r -v > Verbose not necessary, but good for letting you know things are progressing >4 - Confirm the mapping change shows in the interface >5 - Confirm reindex worked and searching is working > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > misc/search_tools/rebuild_elasticsearch.pl | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > >diff --git a/misc/search_tools/rebuild_elasticsearch.pl b/misc/search_tools/rebuild_elasticsearch.pl >index 9ac93d4860..78b7a41639 100755 >--- a/misc/search_tools/rebuild_elasticsearch.pl >+++ b/misc/search_tools/rebuild_elasticsearch.pl >@@ -27,6 +27,13 @@ rebuild_elasticsearch.pl - inserts records from a Koha database into Elasticsear > > B<rebuild_elasticsearch.pl> > [B<-c|--commit>=C<count>] >+[B<-d|--delete>] >+[B<-r|--reset>] >+[B<-a|--authorities>] >+[B<-b|--biblios>] >+[B<-bn|--bnumber>] >+[B<-ai|--authid>] >+[B<-p|--processes>] > [B<-v|--verbose>] > [B<-h|--help>] > [B<--man>] >@@ -48,6 +55,11 @@ Higher should be faster, but will cause more RAM usage. Default is 5000. > > Delete the index and recreate it before indexing. > >+=item B<-r|--reset> >+ >+Reload mappings from files (specified in koha-conf.xml) before indexing. >+Implies --delete. >+ > =item B<-a|--authorities> > > Index the authorities only. Combining this with B<-b> is the same as >@@ -98,7 +110,9 @@ use Koha::Script; > use C4::Context; > use Koha::MetadataRecord::Authority; > use Koha::BiblioUtils; >+use Koha::SearchEngine::Elasticsearch; > use Koha::SearchEngine::Elasticsearch::Indexer; >+use Koha::Caches; > use MARC::Field; > use MARC::Record; > use Modern::Perl; >@@ -106,7 +120,7 @@ use Pod::Usage; > > my $verbose = 0; > my $commit = 5000; >-my ($delete, $help, $man, $processes); >+my ($delete, $reset, $help, $man, $processes); > my ($index_biblios, $index_authorities); > my (@biblionumbers,@authids); > >@@ -115,6 +129,7 @@ $|=1; # flushes output > GetOptions( > 'c|commit=i' => \$commit, > 'd|delete' => \$delete, >+ 'r|reset' => \$reset, > 'a|authorities' => \$index_authorities, > 'b|biblios' => \$index_biblios, > 'bn|bnumber=i' => \@biblionumbers, >@@ -139,6 +154,14 @@ pod2usage( -exitstatus => 0, -verbose => 2 ) if $man; > > _sanity_check(); > >+if ($reset){ >+ Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; >+ my $cache = Koha::Caches->get_instance(); >+ $cache->clear_from_cache('elasticsearch_search_fields_staff_client'); >+ $cache->clear_from_cache('elasticsearch_search_fields_opac'); >+ $delete = 1; >+} >+ > _verify_index_state($Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX, $delete) if ($index_biblios); > _verify_index_state($Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX, $delete) if ($index_authorities); > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23137
:
101051
|
101052
|
102354
|
102355
|
102918
|
103014
|
103640
|
103647
|
103648
|
103649
|
103650