ElasticSearch documentation is exhaustive, but the way it’s structured has some room for improvement. This post is meant as a cheat-sheet entry point into ElasticSearch APIs.<!--more-→
Category | Description | Call examples | |
---|---|---|---|
Single Document API |
PUT /my_index/my_type/1 { "my_field" : "my_value" } POST /my_index/my_type { ... } PUT /my_index/my_type/1/_create { ... } |
||
GET /my_index/my_type/0 |
|||
DELETE /my_index/my_type/0 |
|||
PUT /my_index/my_type/1 { ... } |
|||
Multi-Document API |
GET /_mget { "docs" : [ { "_index" : "my_index", "_type" : "my_type", "_id" : "1" } ] } GET /my_index/_mget { "docs" : [ { "_type" : "my_type", "_id" : "1" } ] } GET /my_index/my_type/_mget { "docs" : [ { "_id" : "1" } ] } |
||
POST /my_index/_delete_by_query { "query": { "match": { ... } } } |
|||
POST /my_index/_update_by_query?conflicts=proceed POST /my_index/_update_by_query?conflicts=proceed { "query": { "term": { "my_field": "my_value" } } } POST /my_index1,my_index2/my_type1,my_type2/_update_by_query |
|||
POST /_reindex { "source": { "index": "old_index" }, "dest": { "index": "new_index" } } |
|||
URI Search |
GET /my_index/my_type/_search?q=my_field:my_value GET /my_index/my_type/_search { "query" : { "term" : { "my_field" : "my_value" } } } |
||
Search Shards API |
GET /my_index/_search_shards |
||
Count API |
GET /my_index/my_type/_count?q=my_field:my_value GET /my_index/my_type/_count { "query" : { "term" : { "my_field" : "my_value" } } } |
||
Validate API |
GET /my_index/my_type/_validate?q=my_field:my_value GET /my_index/my_type/_validate { "query" : { "term" : { "my_field" : "my_value" } } } |
||
Explain API |
GET /my_index/my_type/0/_explain { "query" : { "match" : { "message" : "elasticsearch" } } } GET /my_index/my_type/0/_explain?q=message:elasticsearch |
||
Profile API |
Provides timing information on individual components during a search |
GET /_search { "profile": true, "query" : { ... } } |
|
Field Stats API |
Finds statistical properties of fields without executing a search |
GET /_field_stats?fields=my_field GET /my_index/_field_stats?fields=my_field GET /my_index1,my_index2/_field_stats?fields=my_field |
|
PUT /my_index { "settings" : { ... } } |
|||
DELETE /my_index DELETE /my_index1,my_index2 DELETE /my_index* DELETE /_all |
|||
GET /my_index GET /my_index* GET my_index/_settings,_mappings |
|||
HEAD /my_index |
|||
POST /my_index/_close POST /my_index/_open |
|||
POST /my_index/_rollover { "conditions": { ... } } |
|||
PUT /my_index/_mapping/new_type { "properties": { "my_field": { "type": "text" } } } |
|||
GET /my_index/_mapping/my_type/field/my_field GET /my_index1,my_index2/_mapping/my_type/field/my_field GET /_all/_mapping/my_type1,my_type2/field/my_field1,my_field2 GET /_all/_mapping/my_type1*/field/my_field* |
|||
HEAD /my_index/_mapping/my_type |
|||
POST /_aliases { "actions" : [ { "add" : { "index" : "my_index", "alias" : "my_alias" } } ] } POST /_aliases { "actions" : [ { "add" : { "index" : ["index1", "index2"] , "alias" : "another_alias" } } ] } |
|||
POST /_aliases { "actions" : [ { "remove" : { "index" : "my_index", "alias" : "my_old_alias" } } ] } |
|||
PUT /my_index/_settings { ... } |
|||
GET /my_index/_settings |
|||
Performs an analysis process of a text and return the tokens |
GET /_analyze { "analyzer" : "standard", "text" : "this is a test" } |
||
PUT /_template/my_template { ... } |
|||
DELETE /_template/my_template |
|||
GET /_template/my_template |
|||
HEAD /_template/my_template |
|||
Replica configuration |
|||
GET /_stats GET /my_index1/_stats GET /my_index1,my_index2/_stats GET /my_index1/_stats/flush,merge |
|||
GET /_segments GET /my_index1/_segments GET /my_index1,my_index2/_segments |
|||
GET /_recovery GET /my_index1/_recovery GET /my_index1,my_index2/_recovery |
|||
GET /_shard_stores GET /my_index1/_shard_stores GET /my_index1,my_index2/_shard_stores |
|||
POST /_cache/clear POST /my_index/_cache/clear POST /my_index1,my_index2/_cache/clear |
|||
POST /_refresh POST /my_index/_refresh POST /my_index1,my_index2/_refresh |
|||
POST /_flush POST /my_index/_flush POST /my_index1,my_index2/_flush |
|||
POST /_forcemerge?max_num_segments=1 POST /my_index/_forcemerge?max_num_segments=1 POST /my_index1,my_index2/_forcemerge?max_num_segments=1 |
|||
cat aliases |
Shows information about aliases, including filter and routing infos |
GET /_cat/aliases?v GET /_cat/aliases/my_alias?v |
|
cat allocations |
Provides a snapshot on how many shards are allocated and how much disk space is used for each node |
GET /_cat/allocation?v |
|
cat count |
GET /_cat/count?v GET /_cat/count/my_index?v |
||
cat fielddata |
GET /_cat/fielddata?v GET /_cat/fielddata/my_field1,my_field2?v |
||
cat health |
One-line representation of the same information from |
GET /_cat/health?v GET /_cat/health?v&ts=0 |
|
cat indices |
GET /_cat/indices?v GET /_cat/indices?v&s=index GET /_cat/indices?v&health=yellow GET /_cat/indices/my_index*?v&health=yellow |
||
cat master |
Displays the master’s node ID, bound IP address, and node name |
GET /_cat/master?v |
|
cat nodeattrs |
GET /_cat/nodeattrs?v GET /_cat/nodeattrs?v&h=name,id,pid,ip |
||
cat nodes |
GET /_cat/nodes?v GET /_cat/nodes?v&h=name,id,pid,ip |
||
cat pending tasks |
Provides the same information as |
GET /_cat/pending_tasks?v |
|
cat plugins |
GET /_cat/plugins?v GET /_cat/plugins?v&h=name,id,pid,ip |
||
cat recovery |
GET /_cat/recovery?v GET /_cat/recovery?v&h=name,id,pid,ip |
||
cat repositories |
GET /_cat/repositories?v |
||
cat thread pool |
GET /_cat/thread_pool?v GET /_cat/thread_pool?v&h=id,pid,ip |
||
cat shards |
GET /_cat/shards?v GET /_cat/shards/my_index?v GET /_cat/shards/my_ind*?v |
||
cat segments |
Provides information similar to |
GET /_cat/segments?v GET /_cat/segments/my_index?v GET /_cat/segments/my_index1,my_index2?v |
|
cat snapshots |
/_cat/snapshots/my_repo?v |
||
cat templates |
GET /_cat/templates?v GET /_cat/templates/my_template GET /_cat/templates/my_template* |
||
Cluster Health |
GET /_cluster/health GET /_cluster/health?wait_for_status=yellow&timeout=50s GET /_cluster/health/my_index1 GET /_cluster/health/my_index1,my_index2 |
||
Cluster State |
GET /_cluster/state GET /_cluster/state/version,nodes/my_index1 GET /_cluster/state/version,nodes/my_index1,my_index2 GET /_cluster/state/version,nodes/_all |
||
Cluster Stats |
GET /_cluster/stats GET /_cluster/stats?human&pretty |
||
Pending cluster tasks |
GET /_cluster/pending_tasks |
||
Cluster Reroute |
GET /_cluster/reroute { ... } |
||
Cluster Update Settings |
GET /_cluster/settings { "persistent" : { ... }, "transient" : { ... } } |
||
Node Stats |
GET /_nodes/stats GET /_nodes/my_node1,my_node2/stats GET /_nodes/127.0.0.1/stats GET /_nodes/stats/indices,os,process |
||
Node Info |
GET /_nodes GET /_nodes/my_node1,my_node2 GET /_nodes/_all/indices,os,process GET /_nodes/indices,os,process GET /_nodes/my_node1,my_node2/_all |
||
Task Management API |
Retrieve information about tasks currently executing on nodes in the cluster |
GET /_tasks GET /_tasks?nodes=my_node1,my_node2 GET /_tasks?nodes=my_node1,my_node2&actions=cluster:* |
|
Nodes Hot Threads |
GET /_nodes/hot_threads GET /_nodes/hot_threads/my_node GET /_nodes/my_node1,my_node2/hot_threads |
||
Cluster Allocation Explain API |
GET /_cluster/allocation/explain GET /_cluster/allocation/explain { "index": "myindex", "shard": 0, "primary": false } |
||
marks an experimental (respectively new) API that is subject to removal (resp. change) in future versions |
Last updated on Feb. 22th |