Skip to content

Commit 183b176

Browse files
ericholscheragjohnson
authored andcommitted
Revert "Merge pull request #4636 from rtfd/search_upgrade" (#4716)
This reverts commit 182ab8d, reversing changes made to 6261427.
1 parent f0bdcbf commit 183b176

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1436
-1431
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python:
44
- 3.6
55
sudo: false
66
env:
7-
- ES_VERSION=6.2.4 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
7+
- ES_VERSION=1.3.9 ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
88
matrix:
99
include:
1010
- python: 3.6

conftest.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
22
import pytest
3-
from django.conf import settings
4-
from rest_framework.test import APIClient
53

64
try:
75
# TODO: this file is read/executed even when called from ``readthedocsinc``,
@@ -46,7 +44,3 @@ def pytest_configure(config):
4644
@pytest.fixture(autouse=True)
4745
def settings_modification(settings):
4846
settings.CELERY_ALWAYS_EAGER = True
49-
50-
@pytest.fixture
51-
def api_client():
52-
return APIClient()
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
==========================================
2+
Enabling Elasticsearch on the local server
3+
==========================================
4+
5+
Read the Docs has been using Elasticsearch for indexing and searching. To enable this on your local installation, you need to install elasticsearch and run the Elastic server locally.
6+
7+
Installation has been mainly divided into following steps.
8+
9+
Installing Java
10+
---------------
11+
12+
Elasticsearch requires Java 8 or later. Use `Oracle official documentation <http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_.
13+
or opensource distribution like `OpenJDK <http://openjdk.java.net/install/>`_.
14+
15+
After installing java, verify the installation by,::
16+
17+
$ java -version
18+
19+
The result should be something like this::
20+
21+
openjdk version "1.8.0_151"
22+
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
23+
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
24+
25+
26+
Downloading and installing Elasticsearch
27+
----------------------------------------
28+
29+
Elasticsearch can be downloaded directly from elastic.co. For Ubuntu, it's best to use the deb (Debian) package which will install everything you need to run Elasticsearch.
30+
31+
RTD currently uses elasticsearch 1.x which can be easily downloaded and installed from `elastic.co
32+
<https://www.elastic.co/downloads/past-releases/elasticsearch-1-3-8/>`_.
33+
34+
Install the downloaded package by following command::
35+
36+
$ sudo apt install .{path-to-downloaded-file}/elasticsearch-1.3.8.deb
37+
38+
Custom setup
39+
------------
40+
41+
You need the icu plugin::
42+
43+
$ elasticsearch/bin/plugin -install elasticsearch/elasticsearch-analysis-icu/2.3.0
44+
45+
Running Elasticsearch from command line
46+
---------------------------------------
47+
48+
Elasticsearch is not started automatically after installation. How to start and stop Elasticsearch depends on whether your system uses SysV init or systemd (used by newer distributions). You can tell which is being used by running this command::
49+
50+
$ ps -p 1
51+
52+
**Running Elasticsearch with SysV init**
53+
54+
Use the ``update-rc.d command`` to configure Elasticsearch to start automatically when the system boots up::
55+
56+
$ sudo update-rc.d elasticsearch defaults 95 10
57+
58+
Elasticsearch can be started and stopped using the service command::
59+
60+
$ sudo -i service elasticsearch start
61+
$ sudo -i service elasticsearch stop
62+
63+
If Elasticsearch fails to start for any reason, it will print the reason for failure to STDOUT. Log files can be found in /var/log/elasticsearch/.
64+
65+
**Running Elasticsearch with systemd**
66+
67+
To configure Elasticsearch to start automatically when the system boots up, run the following commands::
68+
69+
$ sudo /bin/systemctl daemon-reload
70+
$ sudo /bin/systemctl enable elasticsearch.service
71+
72+
Elasticsearch can be started and stopped as follows::
73+
74+
$ sudo systemctl start elasticsearch.service
75+
$ sudo systemctl stop elasticsearch.service
76+
77+
To verify run::
78+
79+
$ curl http://localhost:9200
80+
81+
82+
You should get something like::
83+
84+
{
85+
status: 200,
86+
name: "Amina Synge",
87+
version: {
88+
number: "1.3.8",
89+
build_hash: "475733ee0837fba18c00c3ee76cd49a08755550c",
90+
build_timestamp: "2015-02-11T14:45:42Z",
91+
build_snapshot: false,
92+
lucene_version: "4.9"
93+
},
94+
tagline: "You Know, for Search"
95+
}
96+
97+
Index the data available at RTD database
98+
----------------------------------------
99+
100+
You need to create the indexes::
101+
102+
$ python manage.py provision_elasticsearch
103+
104+
In order to search through the RTD database, you need to index it into the elasticsearch index::
105+
106+
$ python manage.py reindex_elasticsearch
107+
108+
You are ready to go!

docs/development/search.rst

Lines changed: 0 additions & 110 deletions
This file was deleted.

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ Information about development is also available:
9696

9797
changelog
9898
install
99-
development/search
10099
architecture
101100
tests
102101
docs

docs/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ need to install Python 2.7 with virtualenv in your system as well.
5757
If you want full support for searching inside your Read the Docs
5858
site you will need to install Elasticsearch_.
5959

60-
Follow :doc:`/development/search` documentation for more instruction.
60+
Ubuntu users could install this package by following :doc:`/custom_installs/elasticsearch`.
6161

6262
.. note::
6363

docs/settings.rst

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -100,81 +100,3 @@ ALLOW_ADMIN
100100
Default: :djangosetting:`ALLOW_ADMIN`
101101

102102
Whether to include `django.contrib.admin` in the URL's.
103-
104-
105-
ELASTICSEARCH_DSL
106-
-----------------
107-
108-
Default:
109-
110-
.. code-block:: python
111-
112-
{
113-
'default': {
114-
'hosts': '127.0.0.1:9200'
115-
},
116-
}
117-
118-
Settings for elasticsearch connection.
119-
This settings then pass to `elasticsearch-dsl-py.connections.configure`_
120-
121-
122-
ES_INDEXES
123-
----------
124-
125-
Default:
126-
127-
.. code-block:: python
128-
129-
{
130-
'project': {
131-
'name': 'project_index',
132-
'settings': {'number_of_shards': 5,
133-
'number_of_replicas': 0
134-
}
135-
},
136-
'page': {
137-
'name': 'page_index',
138-
'settings': {
139-
'number_of_shards': 5,
140-
'number_of_replicas': 0,
141-
}
142-
},
143-
}
144-
145-
Define the elasticsearch name and settings of all the index separately.
146-
The key is the type of index, like ``project`` or ``page`` and the value is another
147-
dictionary containing ``name`` and ``settings``. Here the ``name`` is the index name
148-
and the ``settings`` is used for configuring the particular index.
149-
150-
151-
ES_TASK_CHUNK_SIZE
152-
------------------
153-
154-
Default: :djangosetting:`ES_TASK_CHUNK_SIZE`
155-
156-
The maximum number of data send to each elasticsearch indexing celery task.
157-
This has been used while running ``elasticsearch_reindex`` management command.
158-
159-
160-
ES_PAGE_IGNORE_SIGNALS
161-
----------------------
162-
163-
Default: ``False``
164-
165-
This settings is used to determine whether to index each page separately into elasticsearch.
166-
If the setting is ``True``, each ``HTML`` page will not be indexed separately but will be
167-
indexed by bulk indexing.
168-
169-
170-
ELASTICSEARCH_DSL_AUTOSYNC
171-
--------------------------
172-
173-
Default: ``True``
174-
175-
This setting is used for automatically indexing objects to elasticsearch.
176-
``False`` by default in development so it is possible to create
177-
project and build documentations without having elasticsearch.
178-
179-
180-
.. _elasticsearch-dsl-py.connections.configure: https://elasticsearch-dsl.readthedocs.io/en/stable/configuration.html#multiple-clusters
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)