At Will & Skill we frequently use ElasticSearch in our project. This is a step-by-step guide on how You can install and use ElasticSearch 5.x in your project.
Look for OpenJDK in APT
$ sudo apt search openjdk
Install OpenJDK 8
$ sudo apt-get install openjdk-8-jdk
Add the proper GPG key for ElasticSearch
$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
Make sure to install/update transport
$ sudo apt-get install apt-transport-https
Save the repo definition
$ echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
Update APT and install ElasticSearch from APT
$ sudo apt-get update && sudo apt-get install elasticsearch
Reload the daemon
$ sudo /bin/systemctl daemon-reload
Allow ElasticSearch to start on boot
$ sudo /bin/systemctl enable elasticsearch.service
Lets fire up ElasticSearch...
$ sudo systemctl start elasticsearch.service
Lets see if we have some logs
$ sudo ls -la /var/log/elasticsearch/
Have a look at the logs and make sure that ElasticSearch has properly initiated
sudo cat /var/log/elasticsearch/elasticsearch.log
If logs are looking good, You can CURL the ElasticSearch server
$ curl -XGET 'localhost:9200/?pretty'
The output should be something like this
{
"name" : "c29HHBX",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "LweifnvTSKeP12nRNu0DAg",
"version" : {
"number" : "5.6.10",
"build_hash" : "b727a60",
"build_date" : "2018-06-06T15:48:34.860Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
Happy coding!