Skip to content

Instantly share code, notes, and snippets.

@Sakib37
Last active January 8, 2019 15:01
Show Gist options
  • Save Sakib37/5095c2d86d3de5ca6db4efdd32ecd9b8 to your computer and use it in GitHub Desktop.
Save Sakib37/5095c2d86d3de5ca6db4efdd32ecd9b8 to your computer and use it in GitHub Desktop.

export ES_HOST=https://MY_ELASTIC_HOST

Task Command Comment
List indices: curl "${ES_HOST}/_cat/indices?v"
Delete indices: curl -XDELETE "${ES_HOST}/index1,index2" Delete index1 and index2
Cluster migration Status: curl -XGET "${ES_HOST}/_cat/recovery?v&active_only" Output of this command should vary over time period (ex- 1 mintue)
Shards Status: curl -XGET "${ES_HOST}/_cat/allocation?v" Shards are allocated to each data node and how much disk space they are using
Number of shards: curl "${ES_HOST}/_cat/shards" Shards are allocated to each data node and how much disk space they are using
Shards status curl -XPUT ${ES_HOST}/index-name -H 'Content-Type: application/ json' -d'{
  "settings": {
    "index": {
      "number_of_shards": 3,
      "number_of_replicas": 1
    }
  }
}'
 
To specify the number of shards in a new index
Define an index template curl -XPUT ${ES_HOST}/_template/template_1 -H 'Content-Type: application/ json' -d'{
  "index_patterns": ["*"],
  "settings": {
      "number_of_shards": 3,
      "number_of_replicas": 1
  }
}'
 
This specifies the number of shards for all new indices that will be created in the cluster
Re-index curl -XPOST ${ES_HOST}/_reindex -H 'Content-Type: application/ json' -d'{
  "source": {
    "index": "old_index"
  },
  "dest": {
    "index": "new_index"
  }
}'
 
This specifies the number of shards for all new indices that will be created in the cluster
Verify Indexes: curl -XGET {ES_HOST}/_cat/indices/old_index,new_index?v Verify that the new index and the old index have the same number of documents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment