Skip to content

Commit

Permalink
Revert "Merge pull request #4636 from rtfd/search_upgrade" (#4716)
Browse files Browse the repository at this point in the history
This reverts commit 182ab8d, reversing
changes made to 6261427.
  • Loading branch information
ericholscher authored and agjohnson committed Oct 3, 2018
1 parent f0bdcbf commit 183b176
Show file tree
Hide file tree
Showing 59 changed files with 1,436 additions and 1,431 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:
- 3.6
sudo: false
env:
- ES_VERSION=6.2.4 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
- ES_VERSION=1.3.9 ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
matrix:
include:
- python: 3.6
Expand Down
6 changes: 0 additions & 6 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
import pytest
from django.conf import settings
from rest_framework.test import APIClient

try:
# TODO: this file is read/executed even when called from ``readthedocsinc``,
Expand Down Expand Up @@ -46,7 +44,3 @@ def pytest_configure(config):
@pytest.fixture(autouse=True)
def settings_modification(settings):
settings.CELERY_ALWAYS_EAGER = True

@pytest.fixture
def api_client():
return APIClient()
108 changes: 108 additions & 0 deletions docs/custom_installs/elasticsearch.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
==========================================
Enabling Elasticsearch on the local server
==========================================

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.

Installation has been mainly divided into following steps.

Installing Java
---------------

Elasticsearch requires Java 8 or later. Use `Oracle official documentation <http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_.
or opensource distribution like `OpenJDK <http://openjdk.java.net/install/>`_.

After installing java, verify the installation by,::

$ java -version

The result should be something like this::

openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)


Downloading and installing Elasticsearch
----------------------------------------

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.

RTD currently uses elasticsearch 1.x which can be easily downloaded and installed from `elastic.co
<https://www.elastic.co/downloads/past-releases/elasticsearch-1-3-8/>`_.

Install the downloaded package by following command::

$ sudo apt install .{path-to-downloaded-file}/elasticsearch-1.3.8.deb

Custom setup
------------

You need the icu plugin::

$ elasticsearch/bin/plugin -install elasticsearch/elasticsearch-analysis-icu/2.3.0

Running Elasticsearch from command line
---------------------------------------

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::

$ ps -p 1

**Running Elasticsearch with SysV init**

Use the ``update-rc.d command`` to configure Elasticsearch to start automatically when the system boots up::

$ sudo update-rc.d elasticsearch defaults 95 10

Elasticsearch can be started and stopped using the service command::

$ sudo -i service elasticsearch start
$ sudo -i service elasticsearch stop

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/.

**Running Elasticsearch with systemd**

To configure Elasticsearch to start automatically when the system boots up, run the following commands::

$ sudo /bin/systemctl daemon-reload
$ sudo /bin/systemctl enable elasticsearch.service

Elasticsearch can be started and stopped as follows::

$ sudo systemctl start elasticsearch.service
$ sudo systemctl stop elasticsearch.service

To verify run::

$ curl http://localhost:9200


You should get something like::

{
status: 200,
name: "Amina Synge",
version: {
number: "1.3.8",
build_hash: "475733ee0837fba18c00c3ee76cd49a08755550c",
build_timestamp: "2015-02-11T14:45:42Z",
build_snapshot: false,
lucene_version: "4.9"
},
tagline: "You Know, for Search"
}

Index the data available at RTD database
----------------------------------------

You need to create the indexes::

$ python manage.py provision_elasticsearch

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

$ python manage.py reindex_elasticsearch

You are ready to go!
110 changes: 0 additions & 110 deletions docs/development/search.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ Information about development is also available:

changelog
install
development/search
architecture
tests
docs
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ need to install Python 2.7 with virtualenv in your system as well.
If you want full support for searching inside your Read the Docs
site you will need to install Elasticsearch_.

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

.. note::

Expand Down
78 changes: 0 additions & 78 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,81 +100,3 @@ ALLOW_ADMIN
Default: :djangosetting:`ALLOW_ADMIN`

Whether to include `django.contrib.admin` in the URL's.


ELASTICSEARCH_DSL
-----------------

Default:

.. code-block:: python
{
'default': {
'hosts': '127.0.0.1:9200'
},
}
Settings for elasticsearch connection.
This settings then pass to `elasticsearch-dsl-py.connections.configure`_


ES_INDEXES
----------

Default:

.. code-block:: python
{
'project': {
'name': 'project_index',
'settings': {'number_of_shards': 5,
'number_of_replicas': 0
}
},
'page': {
'name': 'page_index',
'settings': {
'number_of_shards': 5,
'number_of_replicas': 0,
}
},
}
Define the elasticsearch name and settings of all the index separately.
The key is the type of index, like ``project`` or ``page`` and the value is another
dictionary containing ``name`` and ``settings``. Here the ``name`` is the index name
and the ``settings`` is used for configuring the particular index.


ES_TASK_CHUNK_SIZE
------------------

Default: :djangosetting:`ES_TASK_CHUNK_SIZE`

The maximum number of data send to each elasticsearch indexing celery task.
This has been used while running ``elasticsearch_reindex`` management command.


ES_PAGE_IGNORE_SIGNALS
----------------------

Default: ``False``

This settings is used to determine whether to index each page separately into elasticsearch.
If the setting is ``True``, each ``HTML`` page will not be indexed separately but will be
indexed by bulk indexing.


ELASTICSEARCH_DSL_AUTOSYNC
--------------------------

Default: ``True``

This setting is used for automatically indexing objects to elasticsearch.
``False`` by default in development so it is possible to create
project and build documentations without having elasticsearch.


.. _elasticsearch-dsl-py.connections.configure: https://elasticsearch-dsl.readthedocs.io/en/stable/configuration.html#multiple-clusters
33 changes: 33 additions & 0 deletions readthedocs/core/management/commands/provision_elasticsearch.py
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!")
Loading

0 comments on commit 183b176

Please sign in to comment.