ElasticSearch – Data Management – Day 1

Background

Wanted to cover the steps one can take to add data to ElasticSearch.

In this post, we will be using Postman to post JSON payloads.

 

Adding Data

Let us add data

Outline

  1. HTTP Verb
    • POST
  2. URL
    • Syntax :-
      http://[server]:[portNumber]/[index]/[type]/[id]
    • Sample :-
      http://localhost:9200/bible/biblekjv/5

 

Sample

Genesis – Chapter 1 – Verse 1

Image

Payload

  1. Method :- POST
  2. URL :- http://localhost:9200/bible/biblekjv/1

 

JSON/ (application/json)

 


{

	  "bookID"   : 1

	, "book"     :  "Genesis"

	, "chapterID"  : 1

	, "verseID"  : 1

	, "passage"  : "Genesis 1:1"

	, "verse"    : 
		"In the beginning God created the heavens and the earth"

}



 

Genesis – Chapter 1 – Verse 2

Image

Payload

  1. Method :- POST
  2. URL :-
    http://localhost:9200/bible/biblekjv/2

JSON/ (application/json)

 


{

	  "bookID"   : 1

	, "book"     :  "Genesis"

	, "chapterID"  : 1

	, "verseID"  : 2

	, "passage"  : "Genesis 1:2"

	, "verse"    : 
		"Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters."

}

Genesis – Chapter 1 – Verse 3

Image

 

Payload

  1. Method :- POST
  2. URL :-
    http://localhost:9200/bible/biblekjv/3
    

JSON/ (application/json)


{

	  "bookID"   : 1

	, "book"     :  "Genesis"

	, "chapterID"  : 1

	, "verseID"  : 3

	, "passage"  : "Genesis 1:3"

	, "verse"    : 
		"Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters."

}


Genesis – Chapter 1 – Verse 4

Image

 

Payload

  1. Method :- POST
  2. URL :-
    http://localhost:9200/bible/biblekjv/4
    

JSON/ (application/json)


{

	  "bookID"   : 1

	, "book"     :  "Genesis"

	, "chapterID"  : 1

	, "verseID"  : 4

	, "passage"  : "Genesis 1:4"

	, "verse"    : 
		"And God said, 'Let there be light', and there was light."

}


Genesis – Chapter 1 – Verse 5

Image

 

Payload

  1. Method :- POST
  2. URL :-
    http://localhost:9200/bible/biblekjv/5
    

JSON/ (application/json)

 


{

	  "bookID"   : 1

	, "book"     :  "Genesis"

	, "chapterID"  : 1

	, "verseID"  : 5

	, "passage"  : "Genesis 1:5"

	, "verse"    : 
		"God called the light 'day', and the darkness he called 'night'. And there was evening, and there was morning—the first day."

}


 

 

Display Data

Let us display the data we have added

List All

Outline

  1. HTTP Verb
    • GET
  2. URL
    • Syntax :-
      get://[server]:[portNumber]/[index]/[type]/_search
    • Sample :-
      http://localhost:9200/bible/biblekjv/search

 

Sample

Bible/biblekjv

 

List All – Ordered By

Outline

  1. HTTP Verb
    • GET
  2. URL
    • Syntax :-
      get://[server]:[portNumber]/[index]/[type]/_search
    • Sample :-
      http://localhost:9200/bible/biblekjv/_search

 

Sample

Bible/biblekjv

 

Payload

  1. Method :- POST
  2. URL :-
    http://localhost:9200/bible/biblekjv/_search
    

JSON/ (application/json)


{
    "sort" : 
	{
          "bookID": {"order": "asc"}
        , "chapterID": {"order": "asc"}
        , "verseID": {"order": "desc"}
	}
}

 

Output

 

Delete Record

Outline

  1. HTTP Verb
    • DEL
  2. URL
    • Syntax :-
      del://[server]:[portNumber]/[index]/[type]/[id]
      
    • Sample :-
      http://localhost:9200/bible/biblekjv/zbAI6GQBFV2VUI1OYvhg
      

 

Sample

Bible/biblekjv

 

Payload

  1. Method :- DEL
  2. URL :-
    http://localhost:9200/bible/biblekjv/zbAI6GQBFV2VUI1OYvhg
    

JSON/ (application/json)

 

Output

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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