Locally Install ElasticSearch to interact with Magento.


Prerequisites:

  • Install Apt Transport HTTPS

Step 1 – Download and install ElasticSearch

  • Save repository definition

    Note: Bear in mind that last version of elasticsearch (7.x) is not compatible with Magento 2.3.*, so you will need to install elasticsearch 6.x. In case you need to remove elasticsearch for a mistake, this is noted at the end of this post, so you will be able then, to proceed again.
  • Update indexes
  • Install ElasticSearch
Step 2 – Configure ElasticSearch
If everything have been passed properly on the previous step, you should now have the directory /etc/elasticsearch, where all config files are in. You now need to edit elasticsearch.yml in there, for server configurations, so we are going to proceed as follows:

Remove the # character at the beginning of the lines for cluster.name and node.name to uncomment them, and then update their values.

After this, your first configuration changes in the /etc/elasticsearch/elasticsearch.yml file should look like this:


 

Step 3 – Launch ElasticSearch

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

Eitherway, Elasticsearch can be started and stopped as follows:

Step 4 – Test Launch
If Elasticsearch service is ready to use and working fine, you can test it using cURL CLI utility. To do so, Run the simple GET command using cURL to verify the setup.
You will see the Elasticsearch cluster details with the version on your screen.

Request on CLI:


Expected Response:


 

Install required plugins:

Go to elasticsearch home directory:


Install plugins (this should be done per each node):


Restart service:


 

How to uninstall Elasticsearch:

Uninstall elasticsearch


Uninstall elasticsearch and it’s dependent packages


Purging elasticsearch



 

Error logs:

If you need to review or monitor any particular error, those can be found on here:


or


 

Side note:

If you like to install a particular elasticsearch version for a project, you can commit the following steps (In this example, i will install 6.8.12 version):


Then, for every single run: