Create an index template

Set default settings for new indices that match logs-*

curl -X PUT 'http://es:9200/_index_template/logs-tpl' -H 'Content-Type: application/json' -d '{"index_patterns":["logs-*"],"template":{"settings":{"number_of_shards":2}}}'

tool
elasticsearch19 commands
tags
elasticsearch

More elasticsearch commands

  • curl -X PUT 'http://es:9200/_snapshot/my_repo/snap1?wait_for_completion=true'

    Create a cluster snapshot and wait until it finishes

  • curl -s http://localhost:9200/_cluster/health | jq .

    Show cluster status (green, yellow or red), shards and nodes

  • curl -s 'http://localhost:9200/_cat/indices?v&h=index,health,pri,rep,docs.count,store.size&s=store.size:desc'

    Show indices as a table, largest first

  • curl -X DELETE http://localhost:9200/<index>

    Delete an index and all its data, there is no undo

  • curl -s http://localhost:9200/<index>/_settings | jq .

    Check the number of shards and replicas and the refresh interval

all 19 elasticsearch commands