Skip to content

Instantly share code, notes, and snippets.

@garlandkr
Created March 23, 2015 15:42
Show Gist options
  • Save garlandkr/5b007cf5b090b5d381c9 to your computer and use it in GitHub Desktop.
Save garlandkr/5b007cf5b090b5d381c9 to your computer and use it in GitHub Desktop.
Assigning shards in ElasticSearch
# First get the unassigned shard indices
curl -XGET http://localhost:8080/_cat/shards --silent | grep UNASS | awk '{print$1,$2}' | awk '!a[$0]++' > indices.txt
# Now assign them to the proper node.
cat indices.txt | while read -r index shard; do
curl -XPOST 'localhost:8080/_cluster/reroute' -d "{
\"commands\" : [ {
\"allocate\" : {
\"index\" : \"$index\",
\"shard\" : \"$shard\",
\"node\" : \"Mentor\",
\"allow_primary\" : true
}
}
]
}"
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment