#!/bin/bash for index in $(curl -s 'http://192.168.0.234:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq); do for shard in $(curl -s 'http://192.168.0.234:9200/_cat/shards' | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq); do echo $index $shard curl -XPOST '192.168.0.234:9200/_cluster/reroute' -d "{ 'commands' : [ { 'allocate' : { 'index' : $index, 'shard' : $shard, 'node' : '7p7qvMcqTKux54dYmflEyg', 'allow_primary' : true } } ] }" sleep 5 done done