#Check cluster health
GET _cat/health
#Check list of available index(s)
GET _cat/indices
#Push document in bank index of type account with document id 3.
PUT /bank/account/3?pretty
{ "name":"rohit",
"age":"31"
}
#Delete a document
DELETE /bank/account/3
#Update a document by pushing new document with existing ID.
#Fetch all available documents in bank index
GET _cat/bank/
#Bulk documents post [One index-id then document followed by another pair]
POST /bank/account/_bulk?pretty
{"index":{"_id":"1"}}
{"name":"John Doe","age":"21"}
{"index":{"_id":"2"}}
{"name":"Jane Doe","age":"20"}
#fetch all
GET /bank/_search
{
"query": {
"match_all": {}
}
}
#fetch all where name is john
GET /bank/_search
{
"query": {
"match": {
"name": "John"
}
}
}
#sort result on age desc
GET /bank/_search
{
"query": {
"match_all": {}
}, "sort": [
{
"age.keyword": {
"order": "desc"
}
}
]
}
#Limit, from/to, Filter and sort
GET /bank/_search
{"query": {"match": {
"age.keyword": "39"
}}, "sort": [
{
"firstname.keyword": {
"order": "asc"
}
}
],"from": 10,
"size": 20
}
#Filter
GET /bank/_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"range": {
"balance": {
"gte": 20000,
"lte": 30000
}
}
}
}
}
}
#Range and Match[must, should, must_not]
GET /bank/_search
{
"query": {"bool": {
"must": [
{
"range": {
"balance": {
"gte": 4000,
"lte": 5000
}
}}
, {"match": {
"gender.keyword": "M"
}
}
]
}
}
}
#Search using wildcards
GET /bank/account/_search
{"query": {
"wildcard": {
"firstname.keyword": {
"value": "*e*h"
}
}
}}
#Select specific columns(_source)
GET /bank/_search
{
"query": {
"match": {
"employer.keyword": "Zappix"
}
}, "size": 20, "_source": ["employer", "firstname"]
}