Elasticsearch has a lot to offer, here’s just some of the
● RESTful API for querying and inserting data
● Massive aggregations abilities
● Custom and pre-made “analyzers” / ”tokenizers”
● It’s easy to scale and cluster
● “Discovery” and “Transport”
● It uses “Sharding” and “Voting” for better performance
Only masters get to “Vote” (and hold data).
Data nodes are just keeping your data safe.
Load balancers are nodes that holds no data and don’t get to
So… How many “Masters” do I need?
9200-9299 for HTTP Access
9300-9400 for Discovery
& Transport Protocol
C - Create
R - Retrieve
U - Update
D - Delete
Indexes are like databases, each index holds multiple types
(tables) and each type define the documents in it (records).
A document is the JSON implementation of each entity, and has
many fields with different attributes.
● Java 7 is strongly preferred over Java 6. Either Oracle
or OpenJDK are acceptable.
● Download and Install
● Run curl -X GET http://localhost:9200 (Or browse with Chrome)
● Add this collection to your Postman
Create a new index for “posts”:
curl -XPUT 'localhost:9200/my_index’
"acknowledged" : true
Try to create it again and it throws exception.
From now on, we call it “Mapping” (oohhh… fancy!)
Each index has one or more mapping types, which are used to divide the documents in an
index into logical groups. User documents might be stored in a user type, and blog posts
in a blogpost type.
So Let’s create an Index with Mapping (postman)
Now open your postman and:
1.Create your first tweet
2.Create a formatted tweet
3.Update your tweet
4.Request a specific version
5.Delete your tweet
6.Delete your Index
Download and run some test data
To query Elasticsearch we use QueryDSL, and we send the query JSON to the
server via POST method.
QueryDSL is consisting of two types of clauses:
1. Leaf query clauses: looks for a particular value in a particular field
2. Compound query clauses: Compound query clauses wrap other leaf or compound