Skip to content

Commit

Permalink
feat: added single core empty feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvanr committed Aug 28, 2023
1 parent 3923b87 commit c017ebf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions direct_indexing/direct_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ def clear_indices():
raise pysolr.SolrError


def clear_indices_for_core(core):
"""
Clear all indices as indicated by the 'cores' variable.
"""
try:
logging.info(f'clear_indices:: Clearing {core} core')
solr = pysolr.Solr(f'{settings.SOLR_URL}/{core}', always_commit=True)
solr.delete(q='*:*')
logging.info(f'clear_indices:: Finished clearing {core} core')
return 'Success'
except pysolr.SolrError:
logging.error('clear_indices:: Could not clear indices')
raise pysolr.SolrError


# Subsets of the indexing process
def run_publisher_metadata():
result = index_publisher_metadata()
Expand Down
9 changes: 9 additions & 0 deletions direct_indexing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ def clear_all_cores():
return direct_indexing.clear_indices()


@shared_task
def clear_cores_with_name(core="publisher"):
"""
Simply trigger process clearing all solr cores.
"""
logging.info("clear_all_cores:: Starting direct indexing clear all cores.")
return direct_indexing.clear_indices_for_core(core)


@shared_task
def start(update=False):
# Only if the most recent data dump was a success
Expand Down

0 comments on commit c017ebf

Please sign in to comment.