Skip to content

Written guide for elasticsearch local #3881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions docs/guides/run-elasticsearch-local.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
==========================================
Enabling Elasticsearch on the local server
==========================================

Read the Docs has been using Elasticsearch which is a platform for distributed search and analysis of data in real time. To enable the search feature on your local installation, you need to install the elasticsearch locally and run the Elastic server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: Please wrap lines at 80 characters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajujha373 @berkerpeksag actually, rtd doesn't use that style of wrapping all lines to 80 characters, here are the guidelines for writing docs https://docs.readthedocs.io/en/latest/docs.html#content. Note that this was recently added.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the elasticsearch" -> can "the" be dropped here?


Installation has been mainly divided into following steps.

1. Installing Java
------------------

Elasticsearch requires JAVA 8 or later. Use `Oracle official documentation <http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: I don't know which one is correct (Java vs. JAVA) but please use the same style in the documentation.

or opensource distribution like `OpenJDK <http://openjdk.java.net/install/>`_.

After installing java, verify the installation by,::

$ java -version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: Please don't use tab characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean $ sign?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't clear in my earlier comment. I meant don't use the \t character to indent code. See the following comparison:

# With using tab:
	$ java -version

# Without tabs, used four spaces instead:
    $ java -version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed as mentioned 👍


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)


2. Downloading and installing Elasticsearch
-------------------------------------------

Elasticsearch can be downloaded directly from elastic.co in zip, tar.gz, deb, or rpm packages. For Ubuntu, it's best to use the deb (Debian) package which will install everything you need to run Elasticsearch.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop the "in zip, tar.gz, deb, or rpm packages" part to make it brief.


RTD currently uses elasticsearch 1.x which can be easily downloaded and installed from the `Official Website
<https://www.elastic.co/downloads/>`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the Official Website -> from elastic.co


1. First download the deb package version 1.3.8 from this `Link <https://www.elastic.co/downloads/past-releases/elasticsearch-1-3-8>`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd merge the first item with the paragraph above. Since we need to install a specific version of Elasticsearch, we don't need to mention the generic downloads page. We can just link to the download page of 1.3.8.


2. Install the downloaded package by following command
``$ sudo apt install .{path-to-downloaded-file}/elasticsearch-1.3.8.deb``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use a code block instead of ``...``:

2. [...] command::

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


3. 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**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave how to run Elasticsearch to users for several reasons:

  1. There are multiple init systems and it would be nice to not maintain these commands in our documentation.

  2. People may want to add their choice of init system to the documentation and that would also increase the maintenance work.

  3. They also can use it without using any init systems and package managers:

    $ wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.3.8.tar.gz
    $ tar xf elasticsearch-1.3.8.tar.gz
    $ cd elasticsearch-1.3.8/
    $ ./bin/elasticsearch

    I wonder if we should document this method instead since it makes installing and running Elasticsearch without having to deal with different init systems, package managers, and distros.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First I thought of writing exactly the same as mentioned by you (i.e directly downloading the tar file), it was previously covered in #3852 . As the said method has an advantage of not having to maintain the init systems, we have a disadvantage of having to start the elasticsearch server each time we need to run our RTD server locally.


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:

.. code-block:: json

{
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"
}

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] index.::

will be converted to HTML as

[...] index.:

I'd drop the "." character.


$ python manage.py reindex_elasticsearch

You are ready to go!