Skip to content
Snippets Groups Projects
Commit c8f459db authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Drop Solr collections before re-creating them in manage.py reindex

parent 4d92ad94
No related branches found
No related tags found
1 merge request!1850Drop Solr collections before re-creating them in manage.py reindex
......@@ -186,8 +186,11 @@ class Indexer(object):
"""
Drop an existing collection
"""
solr.delete_doc_by_query(self.collection_name, '*:*', **self.solr_options)
logger.info(f'Dropped index for {self.collection_name}')
if solr.collections.exists(self.collection_name):
solr.delete_doc_by_query(self.collection_name, '*:*', **self.solr_options)
logger.info(f'Dropped index for {self.collection_name}')
else:
logger.info(f'Skipping drop for {self.collection_name}: collection does not exist')
def get_elements(self):
# First make the query that returns all indexable elements.
......
......@@ -48,9 +48,9 @@ class Command(BaseCommand):
for corpus in corpora:
self.stdout.write(f"Indexing {corpus.name}")
indexer = Indexer(corpus.id)
indexer.setup()
if options.get('setup'):
return
if options.get('drop'):
indexer.drop_index()
indexer.setup()
if options.get('setup'):
continue
indexer.index()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment