Skip to content

Commit 8a5ce2b

Browse files
authored
Merge pull request #4216 from Jmennius/provision-elasticsearch-command
Add provision_elasticsearch command
2 parents 7d37f48 + 2cc0723 commit 8a5ce2b

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

docs/custom_installs/elasticsearch.rst

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,7 @@ Index the data available at RTD database
9999

100100
You need to create the indexes::
101101

102-
from readthedocs.search.indexes import Index, ProjectIndex, PageIndex, SectionIndex
103-
104-
index = Index()
105-
index_name = index.timestamped_index()
106-
index.create_index(index_name)
107-
index.update_aliases(index_name)
108-
# Update mapping
109-
proj = ProjectIndex()
110-
proj.put_mapping()
111-
page = PageIndex()
112-
page.put_mapping()
113-
sec = SectionIndex()
114-
sec.put_mapping()
102+
$ python manage.py provision_elasticsearch
115103

116104
In order to search through the RTD database, you need to index it into the elasticsearch index::
117105

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Provision Elastic Search"""
2+
3+
from __future__ import absolute_import
4+
import logging
5+
6+
from django.core.management.base import BaseCommand
7+
8+
from readthedocs.search.indexes import Index, PageIndex, ProjectIndex, SectionIndex
9+
10+
log = logging.getLogger(__name__)
11+
12+
13+
class Command(BaseCommand):
14+
15+
help = __doc__
16+
17+
def handle(self, *args, **options):
18+
"""Provision new ES instance"""
19+
index = Index()
20+
index_name = index.timestamped_index()
21+
22+
log.info("Creating indexes..")
23+
index.create_index(index_name)
24+
index.update_aliases(index_name)
25+
26+
log.info("Updating mappings..")
27+
proj = ProjectIndex()
28+
proj.put_mapping()
29+
page = PageIndex()
30+
page.put_mapping()
31+
sec = SectionIndex()
32+
sec.put_mapping()
33+
log.info("Done!")

0 commit comments

Comments
 (0)