diff --git a/elasticsearch-remove-old-indices.sh b/elasticsearch-remove-old-indices.sh index 162297f..ef9832f 100755 --- a/elasticsearch-remove-old-indices.sh +++ b/elasticsearch-remove-old-indices.sh @@ -95,7 +95,7 @@ if [ -n "$ERROR" ]; then fi # Get the indices from elasticsearch -INDICES_TEXT=`curl -s "$ELASTICSEARCH/_status?pretty=true" | grep $GREP | grep -v \"index\" | sort -r | awk -F\" {'print $2'}` +INDICES_TEXT=`curl -s "$ELASTICSEARCH/_cat/indices?v" | awk '/'$GREP'/{match($0, /[:blank]*('$GREP'.[^ ]+)[:blank]*/, m); print m[1];}' | sort -r` if [ -z "$INDICES_TEXT" ]; then echo "No indices returned containing '$GREP' from $ELASTICSEARCH."