-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4216 from Jmennius/provision-elasticsearch-command
Add provision_elasticsearch command
- Loading branch information
Showing
2 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
readthedocs/core/management/commands/provision_elasticsearch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Provision Elastic Search""" | ||
|
||
from __future__ import absolute_import | ||
import logging | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from readthedocs.search.indexes import Index, PageIndex, ProjectIndex, SectionIndex | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
help = __doc__ | ||
|
||
def handle(self, *args, **options): | ||
"""Provision new ES instance""" | ||
index = Index() | ||
index_name = index.timestamped_index() | ||
|
||
log.info("Creating indexes..") | ||
index.create_index(index_name) | ||
index.update_aliases(index_name) | ||
|
||
log.info("Updating mappings..") | ||
proj = ProjectIndex() | ||
proj.put_mapping() | ||
page = PageIndex() | ||
page.put_mapping() | ||
sec = SectionIndex() | ||
sec.put_mapping() | ||
log.info("Done!") |