Difference between revisions of "Elasticsearch Reference Card"
Jump to navigation
Jump to search
| Line 31: | Line 31: | ||
} | } | ||
}' | }' | ||
| + | </pre> | ||
| + | |||
| + | * list all docs in an index | ||
| + | curl -X GET 'http://localhost:9200/elasticsearch_query_examples/_search' | ||
| + | |||
| + | =SHRADS= | ||
| + | * move shards from one node to another | ||
| + | <pre> | ||
| + | curl -XPOST 'http://localhost:9200/_cluster/reroute' -d '{ | ||
| + | "commands" : [ | ||
| + | { | ||
| + | "move" : | ||
| + | { | ||
| + | "index" : "indexname", "shard" : 1, | ||
| + | "from_node" : "nodename", "to_node" : "nodename" | ||
| + | } | ||
| + | } | ||
| + | ] | ||
| + | }';echo | ||
| + | </pre> | ||
| + | |||
| + | * force the allocation of an unassigned shard with a reason | ||
| + | <pre> | ||
| + | curl -XPOST 'http://localhost:9200/_cluster/reroute?explain' -d '{ | ||
| + | "commands" : [ { | ||
| + | "allocate" : { | ||
| + | "index" : "indexname", "shard" : 0, "node" : "nodename" | ||
| + | } | ||
| + | } ] | ||
| + | }';echo | ||
</pre> | </pre> | ||
[[Category:Elastic]] | [[Category:Elastic]] | ||
Revision as of 06:43, 6 November 2021
Contents
1 OVERVIEW
- get version and details
curl -XGET 'http://localhost:9200'
2 CLUSTER AND NODE
curl 'http://localhost:9200/_cluster/health?pretty' curl 'http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=50s&pretty' curl 'http://localhost:9200/_cluster/state?pretty' curl 'http://localhost:9200/_cluster/stats?human&pretty' curl 'http://localhost:9200/_cluster/pending_tasks?pretty' curl 'http://localhost:9200/_nodes?pretty' curl 'http://localhost:9200/_nodes/stats?pretty' curl 'http://localhost:9200/_nodes/nodeId1,nodeId2/stats?pretty'
- full settings
curl 'http://localhost:9200/_cluster/settings?include_defaults=true&flat_settings=true&pretty'
3 INDICES
- list
curl -X GET 'http://localhost:9200/_cat/indices?v'
- delete
curl -X DELETE 'http://localhost:9200/examples'
- back up
curl -XPOST --header 'Content-Type: application/json' http://localhost:9200/_reindex -d '{
"source": {
"index1": "someexamples"
},
"dest": {
"index2": "someexamples_copy"
}
}'
- list all docs in an index
curl -X GET 'http://localhost:9200/elasticsearch_query_examples/_search'
4 SHRADS
- move shards from one node to another
curl -XPOST 'http://localhost:9200/_cluster/reroute' -d '{
"commands" : [
{
"move" :
{
"index" : "indexname", "shard" : 1,
"from_node" : "nodename", "to_node" : "nodename"
}
}
]
}';echo
- force the allocation of an unassigned shard with a reason
curl -XPOST 'http://localhost:9200/_cluster/reroute?explain' -d '{
"commands" : [ {
"allocate" : {
"index" : "indexname", "shard" : 0, "node" : "nodename"
}
} ]
}';echo