Elasticsearch - Installation


Advertisements


The steps for installation of Elasticsearch are as follows −

Step 1 − Check the minimum version of your java in installed your computer, it should be java 7 or more updated version. You can check by doing the following −

In Windows Operating System (OS) (using command prompt) −

> java -version

In UNIX OS (Using Terminal) −

$ echo $JAVA_HOME

Step 2 − Download Elasticsearch from www.elastic.co

  • For windows OS download ZIP file.
  • For UNIX OS download TAR file.
  • For Debian OS download DEB file.
  • For Red Hat and other Linux distributions download RPN file.
  • APT and Yum utilities can also be used to install Elasticsearch in many Linux distributions.

Step 3 − Installation process for Elasticsearch is very easy and described below for different OS −

  • Windows OS − Unzip the zip package and the Elasticsearch is installed.

  • UNIX OS − Extract tar file in any location and the Elasticsearch is installed.

$tar –xvf elasticsearch-2.1.0.tar.gz
  • Using APT utility for Linux OS

    • Download and install the Public Signing Key −

$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
    • Save the repository definition −

$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc
   /apt/sources.list.d/elasticsearch-2.x.list
    • Run update −

$ sudo apt-get update
    • Now you can install by using the following command −

$ sudo apt-get install elasticsearch
  • Using YUM utility for Debian Linux OS

    • Download and install the Public Signing Key −

$ rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
    • ADD the below text in the file with .repo suffix in your “/etc/yum.repos.d/” directory. For example, elasticsearch.repo

[elasticsearch-2.x]
name = Elasticsearch repository for2.x packages
baseurl = https://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck = 1
gpgkey = https://packages.elastic.co/GPG-KEY-elasticsearch
enabled = 1
    • You can now install Elasticsearch by using the following command −

$ yum install elasticsearch

Step 4 − Go to the Elasticsearch home directory and inside the bin folder. Run the elasticsearch.bat file in case of windows or you can do the same using command prompt and through terminal in case of UNIX rum Elasticsearch file.

In Windows

> cd elasticsearch-2.1.0/bin
> elasticsearch

In Linux

$ cd elasticsearch-2.1.0/bin
$ ./elasticsearch

Note − in case of windows, you might get error stating JAVA_HOME is not set, please set it in environment variables to “C:\Program Files\Java\jre1.8.0_31” or the location where you installed java.

Step 5 − Default port for Elasticsearch web interface is 9200 or you can change it by changing http.port inside elasticsearch.yml file present in bin directory. You can check if the server is up and running by browsing https://localhost:9200. It will return a JSON object, which contains the information about the installed Elasticsearch in the following way −

{
   "name" : "Brain-Child",
   "cluster_name" : "elasticsearch", "version" : {
      "number" : "2.1.0",
      "build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87",
      "build_timestamp" : "2015-11-18T22:40:03Z",
      "build_snapshot" : false,
      "lucene_version" : "5.3.1"
   },
   "tagline" : "You Know, for Search"
}

Step 6 − You can install fiddler2 from www.telerik.com as a front end for your Elasticsearch.

  • In the configure window of fiddler2, you can hit the address of Elasticsearch adding an index and if you want, then the type/mapping also using HTTP POST method, for example −

    • Address bar

https://localhost:9200/schools/school
    • Request body − You can add JSON object, which will get store into that index.

  • You can use the same for searching anything by just adding “_search” keyword at the end of URL and sent a query in request body for example −

    • Address bar

POST https://localhost:9200/city/schools/_search
    • Request body

      { "query":{ "match_all":{} } }

      This query will return everything from that index, which belongs to that particular type.

  • You can delete a particular index or type by just putting the URL of the same in address bar and hit it with HTTP DELETE method.



Advertisements