Skip to content

Commit

Permalink
add set_primary command to sharectl
Browse files Browse the repository at this point in the history
make it easy to switch the elasticsearch index used for search:
```
sharectl search set_primary <index_name>
```
  • Loading branch information
aaxelb committed Feb 15, 2021
1 parent 17e81dc commit 88eade8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions share/bin/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def setup(args, argv):
elastic_manager.update_primary_alias(primary_index)


@search.subcommand('Set the "primary" index used to serve search results')
def set_primary(args, argv):
"""
Usage: {0} search set_primary <index_name>
"""
ElasticManager().update_primary_alias(args['<index_name>'])


@search.subcommand('Start the search indexing daemon')
def daemon(args, argv):
"""
Expand Down
2 changes: 1 addition & 1 deletion share/search/elastic_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def update_primary_alias(self, primary_index_name):
pass

if previous_indexes == [primary_index_name]:
logger.info(f'index {primary_index_name} is already the primary')
logger.warn(f'index {primary_index_name} is already the primary')
return

logger.warn(f'removing aliases to {previous_indexes} and adding alias to {primary_index_name}')
Expand Down

0 comments on commit 88eade8

Please sign in to comment.