This Blog will help us to know how to do CRUD operation using ES 5.4 and Java 1.8

1) Download ES- 5.4.2 : and unzip
2) Install Xpack

a) Goto C:\Subhasish\elasticsearch-5.4.2\elasticsearch-5.4.2\bin


b) elasticsearch-plugin install x-pack ( press enter)

Continute twice with Y option

Continue with installation? [y/N]y
Continue with installation? [y/N]y

3) Install Java 1.8

4) Make the following changes in elasticsearch.yml file my-application false false false

5) Create a maven project or include the following jar in build path


6) Create a Java client class :

7) Create a TransportClient  connects remotely to an Elasticsearch cluster using the transport module

Settings settings =Settings.builder().put(“”, “my-application”).build();

TransportClient  client = new PreBuiltTransportClient(settings) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(“”), 9300));

Note : If you dont specify any customized cluster name in your yml file then use “elasticsearch”  instead of  ” my-application” in above code.

Use port 9300 instead of 9200 ( default port used in ES) when you are connecting through TCP


a) C-Create


b) R- read

Get API – allows you to get a typed JSON document, based on the ID, from the index.


Search API


c) U- Update

Note: if field does not exists then it will create a new one


d) D -Delete

Note: After deletion you will status as “Not Found”


Full code:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s