Skip to main content

Getting Started With Elasticsearch

Elasticsearch is open source search system based of Apache Lucene. this is a brief introduction, you can find more information on Elasticsearch Official Site or  Wiki.

What are features of Elasticsearch?

Here are list of features of Elasticsearch.
  • Real Time Search and Analytic.
  • Distributed Data (Scales Horizontally) 
  • Based on Apache Lucene
  • High Availability
  • Full Text Search
  • JSON Based Documents
  • RESTful API
  • Multi Facets
  • Geo Location Search
  • Open Source

How to install ElasticSearch?

Download the latest version from
Then unzip it or use following command in console to download Elasticsearch.

curl -L -O$
unzip elasticsearch-$
cd  elasticsearch-$VERSION

Now move to unzip folder and run following command

{elasticsearch unzip folder path}/bin/elasticsearch

It will start Elasticsearch

How to use ElasticSearch?

To interactive with data using Elasticsearch we will use head plugin of Elasticsearch.

To install head plugin in your system run following command.

{elasticsearch unzip folder path}/bin/plugin --install mobz/elasticsearch-head

After successful installation open your favorite browser and  type following URL to use head plugin.

It will open head plugin user interface, now we can manipulate Elasticsearch records.

To start with data manipulation, first we need to create Index and Type.

Index acts as Database and Type as Table, therefore we can have multiple Type inside single Index.

First create new index, to create new index click button New Index from homepage of head plugin.

Then type name of index (for this blog we type "database" as Index and use Type as "Table") and click Ok.
It will create new index on Elasticsearch.

How to perform CRUD operation on Elasticsearch?

To perform CRUD operation on Elasticsearch select Any Request Tab
It will open user interface as shown below

There are several section defined in above image. lets see them one by one
  • Index: Index on which you want to perform action, it is located just after localhost:9200/
  • Type: Type within selected Index, it will come after Index value.
  • Action: which type of action you want to perform like search, mapping, etc.
  • Action Method: it is REST API action methods like POST, GET, PUT, DELETE.

Following is record or document structure that we are going to create.

   name : String,
   description: String,
   profile_image : String,
   birthdate : Date,
   address: String

Create Mapping:

First new need to define structure of data, by default it would be string for all fields but we can set different data type as date, geo point, etc.

To define mapping, select Index and Type, then type _mapping in Action area to perform mapping related tasks, then select Action Method as POST and type following mapping structure and click on Request button. 

  "table": {
      "name": {"type" : "string"},
      "description": {"type" : "string"},
      "profile_image":{"type" : "string"},
      "birthdate":{"type" : "date"},
      "address":{"type" : "string"}

To ensure mapping is created , just change Action Method to GET and click Request button.

Create Record:

To create record on selected Index and Type, make Action  value empty 
and Action Method as POST after that add following JSON record.

  "name": "Zainul",
  "description" : "Software Developer",
  "birthdate": "1985-03-13T00:00:00",
  "profile_image" : "image1.png"

And click on Request button. It will index the one record.

Read Indexed Records:

To fetch indexed records from Elasticsearch, select Index and Type then Action as _search and Action Method as POST , make query body empty then click on Request button.
It will fetch 10 records from selected Index and Type.

Update Records:

To update value of name field, select Index and Type then Action as _update and Action Method as PUT and add following JSON record in query section then click on Request button.

 "script": "\"Zainul Abedin \""

to check record is updated or not, fire search query.

Delete Records:

To delete record from selected Index and Type, make Action value empty and select Action Method as DELETE and click on Request button.

This is a brief introduction to CRUD operations. in next blog post you will see how to access Elasticsearch via Java Client.


Popular posts from this blog

AngularJs Tutorial: Getting Started

This tutorial will help you to create a dynamic web application using power of AngularJs. ·   What is AngularJs AngularJs is javascript MVC framework (maintained by Google) which molds static HTML application to dynamic web application. That was a brief introduction, you can find more information on Wiki and AngularJS Site . AngularJs follows MVC pattern to separate out model from view and manage it by controller. See this image Goal of using AngularJs is to convert static HTML template to dynamic (Angular) template.   ·   How to convert static template to dynamic (Angular) Template Now consider the following static HTML template which contain list of movies title. <html> <head></head> <body>   <h1>Upcoming Movies</h1> <ul>     <li>       <span>Godzilla</span>     </li> <li>       <span>Batman vs Superman</span>     </li> <li>       <span>Sta

Abstract Factory design pattern analysis

What is Abstract Factory design pattern?     The intent or definition of Abstract Factory is “ Provide an interface for creating families of related or dependent objects without specifying their concrete classes ” It is kind of an obscure definition, in order to understand it we need to break it into meaningful pieces. 1.  " Provide an interface "  When we talk about Abstract Factory we talk about interface not abstract class , Basically this design pattern gives us an Interface, like Interface in Java, C# , Typescript (abstract class).    Why interface?  Whenever we talk about any design pattern, it emphasizes more on how we are going to use it rather than implement it. Interface is always the right type to prefer because concrete class creates tight coupling whereas an interface isolates it from the rest of the system. At runtime we can get different solution, without updating our code. For example interface SecurityFactory

AngularJs Tutorials : Bootstrap

Every application starts with bootstrap process which initialize application and wire it other with dependencies and configurations. AngularJs is not different from other application. It also starts application with bootstrap process. Following operation happens inside AngularJs bootstrap process. Load application module. Create dependency injector and load dependencies. Compile HTML and create scope for application. All these steps happens inside angular.js scripting file. therefore we need to include it first. we can include it inside HEAD tag or at end of BODY tag. Note: Adding angular.js file at end of body tag will allow browser to load of HTML elements without any delay and afterwards load angular.js and begin bootstrapping process. You can get angular.js source file from <script src= ”” type= ”text/javascript” > AngularJs bootstrap process happens on docum