       msg.send("Getting the cat stats for the cluster: #{cluster_url}")
       msg.http("#{cluster_url}/_cat/nodes?h=host,heapPercent,load,segmentsMemory,fielddataMemory,filterCacheMemory,idCacheMemory,percolateMemory,u,heapMax,nodeRole,master")
         .get() (err, res, body) ->
-          msg.send(body)
+          lines  = body.split("\n")
+          header = lines.shift()
+          list   = [header].concat(lines.sort().reverse()).join("\n")
+          msg.send("/code #{list}")
 
-  # node_health = (msg, server) ->
-  #   msg.http("http://#{server}/")
-  #     .get() (err, res, body) ->
-  #       json = JSON.parse(body)
-  #       name = json['name']
-  #       status = json['status']
-  #       msg.send "Server: #{name} \nStatus: #{status}"
+  cat_indexes = (msg, alias) ->
+    cluster_url = _esAliases[alias]
 
-  # robot.respond /elasticsearch query (.*) (.*)/i, (msg) ->
-  #   if msg.message.user.id is robot.name
-  #     return
-  #
-  #   search msg, msg.match[1], msg.match[2], (text) ->
-  #     msg.send(text)
-  #
-  # robot.respond /elasticsearch node (.*)/i, (msg) ->
-  #   if msg.message.user.id is robot.name
-  #     return
-  #
-  #   node_health msg, msg.match[1], (text) ->
-  #     msg.send text
+    if cluster_url == "" || cluster_url == undefined
+      msg.send("No ES Cluster found for #{alias}")
+    else
+      msg.send("Getting the cat indices for the cluster: #{cluster_url}")
+      msg.http("#{cluster_url}/_cat/indices/logstash-*?h=idx,sm,fm,fcm,im,pm,ss,sc,dc&v")
+        .get() (err, res, body) ->
+          lines  = body.split("\n")
+          header = lines.shift()
+          list   = [header].concat(lines.sort().reverse()).join("\n")
+          msg.send("/code #{list}")
 
   robot.hear /elasticsearch cat nodes (.*)/i, (msg) ->
     if msg.message.user.id is robot.name
       return
 
     cat_nodes msg, msg.match[1], (text) ->
+      msg.send text
+
+  robot.hear /elasticsearch cat indexes (.*)/i, (msg) ->
+    if msg.message.user.id is robot.name
+      return
+
+    cat_indexes msg, msg.match[1], (text) ->
       msg.send text
 
   robot.hear /elasticsearch cluster (.*)/i, (msg) ->

  robot.brain.on 'loaded', ->
    if robot.brain.data.elasticsearch_aliases?
      _esAliases = robot.brain.data.elasticsearch_aliases

  # search = (msg, server, query) ->
  #   msg.http("http://#{server}/_search?#{query}")
  #     .get() (err, res, body) ->
  #       json = JSON.parse(body)
  #       firsthit = JSON.stringify(json.hits.hits[0])
  #       msg.send("There are #{json.hits.total} results for the search http://#{server}/_search?#{query} \nThe first result is \n#{firsthit}")

  cluster_health = (msg, alias) ->
    cluster_url = _esAliases[alias]

#
# Commands:
#   hubot: elasticsearch cluster [server] - Gets the cluster information for the given server or alias
#   hubot: elasticsearch cat nodes [server] - Gets the information from the cat nodes endpoint for the given server or alias
#   hubot: elasticsearch cat indexes [server] - Gets the information from the cat indexes endpoint for the given server or alias
#   hubot: elasticsearch show aliases - shows the aliases for the list of ElasticSearch instances
#   hubot: elasticsearch add alias [alias name] [url] - sets the alias for a given url
#   hubot: elasticsearch clear alias [alias name] - please note that this needs to include any port numbers as appropriate
