Saturday, 3 September 2016

How to install and use elastic search server in ubuntu.

Elasticsearch is an open-source search server based on Apache Lucene. It provides a distributed full text search engine with an HTTP web interface and schema-free JSON documents. It is developed in Java and is free available under apache licence. It will give REST which allow you to easily create , delete , update and retrieving of data.

elasticsearch server

How to install elasticsearch in ubuntu:

Step 1 : Installing Elasticsearch

Before start installing elasticsearch update the package in ubuntu using command.

sudo apt-get update

Download the latest Elasticsearch version.


Then install it with Ubuntu way with dpkg.

sudo dpkg -i elasticsearch-2.3.1.deb

The elasticsearch is installed in the directory folder /usr/share/elasticsearch/ with its configuration files placed in /etc/elasticsearch and its init script added in /etc/init.d/elasticsearch.

To check elasticsearch starts and stops automatically with the server add init script.

sudo systemctl enable elasticsearch.service

Check Elasticsearch is Working:

curl -X GET 'http://localhost:9200'
http://localhost:9200 (browser)

  "name" : "Silvermane",
  "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"

Elasticsearch Commands:

Elasticsearch is RESTful API based search server, which responds to the usual CRUD commands: create, read, update, and delete.

curl -X POST 'http://localhost:9200/example/hello/1' -d '{ "message": "Good Morning Elastic!" }'


example is the index of the data in elasticsearch.
hello is the type.
1 is the id of our entry under the above index and type.

You can retrieve this first entry with an HTTP GET request.

curl -X GET 'http://localhost:9200/example/hello/1'


{"_index":"example","_type":"hello","_id":"1","_version":1,"found":true,"_source":{ "message": "Good Morning Elastic!" }}

For more commands you can check the full documentation of elasticsearch . Please read the next post for implementing elasticsearch in Yii2 here.

Featured post

How to create dynamic schema in mongodb

Sometime what we need in our application is to create mongodb schema for collection and some of our collection schema are same but names are...

Popular Posts