<commit_before>#!/bin/sh

ES_HOST=$1

if [ -z $ES_HOST ]; then
	echo "Need es host"
	exit
fi

ES_PORT=$2

if [ -z $ES_PORT ]; then
	echo "Need es port"
	exit
fi

MASTER_NODE=`curl -s "http://$ES_HOST:$ES_PORT/_cat/master?v" | tail -1 | awk '{print $4}'`

if [ -z $MASTER_NODE ]; then
	echo "Failed to get master"
	exit
fi
		

for index in `curl  -s "http://$ES_HOST:$ES_PORT/_cat/shards" | grep UNASSIGNED | awk '{print $1}' | sort | uniq`
do
    for shard in `curl  -s "http://$ES_HOST:$ES_PORT/_cat/shards" | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq`
	do
        echo  $index $shard
        curl -XPOST "http://$ES_HOST:$ES_PORT/_cluster/reroute" -d "{
            \"commands\" : [ {
                  \"allocate\" : {
                      \"index\" : \"$index\",
                      \"shard\" : \"$shard\",
                      \"node\" : \"$MASTER_NODE\",
                      \"allow_primary\" : true
                  }
                }
            ]
        }"

        sleep 5
    done
done
<commit_msg>only show error msg when reroute indices<commit_after>#!/bin/sh

ES_HOST=$1

if [ -z $ES_HOST ]; then
	echo "Need es host"
	exit
fi

ES_PORT=$2

if [ -z $ES_PORT ]; then
	echo "Need es port"
	exit
fi

MASTER_NODE=`curl -s "http://$ES_HOST:$ES_PORT/_cat/master?v" | tail -1 | awk '{print $4}'`

if [ -z $MASTER_NODE ]; then
	echo "Failed to get master"
	exit
fi
		

for index in `curl  -s "http://$ES_HOST:$ES_PORT/_cat/shards" | grep UNASSIGNED | awk '{print $1}' | sort | uniq`
do
    for shard in `curl  -s "http://$ES_HOST:$ES_PORT/_cat/shards" | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq`
	do
        echo  $index $shard

		POST_DATA="{
            \"commands\" : [ {
                  \"allocate\" : {
                      \"index\" : \"$index\",
                      \"shard\" : \"$shard\",
                      \"node\" : \"$MASTER_NODE\",
                      \"allow_primary\" : true
                  }
                }
            ]
        }"

        RESPONSE=`curl -s -w "HTTP_RESPONSE_CODE:%{http_code}" -XPOST "http://$ES_HOST:$ES_PORT/_cluster/reroute" -d "$POST_DATA"`

        if [ `echo $RESPONSE | grep -oP '(?<=HTTP_RESPONSE_CODE:)[0-9]+'`"x" != '200x' ];then
            echo $RESPONSE
		else
			echo "OK"
        fi

        sleep 5
    done
done

{'fraction_non_alphanumeric': 0.16695205479452055, 'fraction_numerical': 0.008133561643835616, 'mean_word_length': 1.7237762237762237, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3822322', 'n_tokens_mistral': 902, 'n_tokens_neox': 832, 'n_words': 211}