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>]
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
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;
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);
GetOptions(
'c|commit=i' => \$commit,
'd|delete' => \$delete,
+ 'r|reset' => \$reset,
'a|authorities' => \$index_authorities,
'b|biblios' => \$index_biblios,
'bn|bnumber=i' => \@biblionumbers,
_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);