layout | title | parent | nav_order |
---|---|---|---|
default |
Popular APIs |
Elasticsearch |
98 |
This page contains sample requests for popular Elasticsearch APIs.
- TOC {:toc}
PUT my-logs
{
"settings": {
"number_of_shards": 4,
"number_of_replicas": 2
},
"mappings": {
"properties": {
"title": {
"type": "text"
},
"year": {
"type": "integer"
}
}
}
}
POST my-logs/_doc
{
"title": "Your Name",
"year": "2016"
}
PUT my-logs/_doc/1
{
"title": "Weathering with You",
"year": "2019"
}
The blank line at the end of the request body is required. If you omit the _id
field, Elasticsearch generates a random ID.
POST _bulk
{ "index": { "_index": "my-logs", "_id": "2" } }
{ "title": "The Garden of Words", "year": 2013 }
{ "index" : { "_index": "my-logs", "_id" : "3" } }
{ "title": "5 Centimeters Per Second", "year": 2007 }
GET _cat/indices?v
POST my-logs*/_open
POST my-logs*/_close
DELETE my-logs*
This request creates the alias my-logs-today
for the index my-logs-2019-11-13
.
PUT my-logs-2019-11-13/_alias/my-logs-today
GET _cat/aliases?v
GET my-logs/_search?q=test
GET my-logs*/_search?q=test
GET _cluster/settings?include_defaults=true
PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.disk.watermark.low": "80%",
"cluster.routing.allocation.disk.watermark.high": "85%"
}
}
GET _cluster/health
GET _cat/nodes?v
GET _nodes/stats
GET _snapshot/my-repository/_all
PUT _snapshot/my-repository/my-snapshot
POST _snapshot/my-repository/my-snapshot/_restore
{
"indices": "-.opendistro_security",
"include_global_state": false
}