Skip to content

Instantly share code, notes, and snippets.

@sharmaabhinav
Last active December 25, 2019 13:25
Show Gist options
  • Save sharmaabhinav/5b50984bfcee88ba8d6e35148c286b94 to your computer and use it in GitHub Desktop.
Save sharmaabhinav/5b50984bfcee88ba8d6e35148c286b94 to your computer and use it in GitHub Desktop.
GET /_cluster/health
GET /_cat/shards?v
GET /_cat/nodes?v
DELETE /pages
GET /_cat/indices?v
PUT /products
{
"settings": {
"number_of_shards": 2,
"number_of_replicas": 2
}
}
DELETE /products
POST /products/_doc
{
"name": "coffemaker",
"price": 64,
"in_stock": 60
}
PUT /products/_doc/100
{
"name": "toaster",
"price": 49,
"in_stock": 4
}
POST /products/_doc/101
{
"name": "toaster1",
"price": 49,
"in_stock": 4
}
GET /products/_doc/100
/* script update */
POST /products/_update/100
{
"script": {
"source": "ctx._source.in_stock = 10"
}
}
/* script update based on params */
POST /products/_update/100
{
"script": {
"source": "ctx._source.in_stock -= params.quantity",
"params": {
"quantity": 4
}
}
}
/* insert if does not exists otherwise update */
POST /products/_update/103
{
"script": {
"source": "ctx._source.in_stock -= 1"
},
"upsert": {
"name": "blendder",
"in_stock": 8,
"price": 45
}
}
/* Delete the doc with id */
DELETE /products/_doc/100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment