     clearAlias msg, msg.match[1], (text) ->
       msg.send(text)
 
-  showAliases = (msg) ->
+  robot.respond /elasticsearch clear cache (.*)/i, (msg) ->
+    if msg.message.user.id is robot.name
+      return
 
-    if _esAliases == null
-      msg.send("I cannot find any ElasticSearch Cluster aliases")
-    else
-      for alias of _esAliases
-        msg.send("I found '#{alias}' as an alias for the cluster: #{_esAliases[alias]}")
-
-  clearAlias = (msg, alias) ->
-    delete _esAliases[alias]
-    robot.brain.data.elasticsearch_aliases = _esAliases
-    msg.send("The cluster alias #{alias} has been removed")
-
-  setAlias = (msg, alias, url) ->
-    _esAliases[alias] = url
-    robot.brain.data.elasticsearch_aliases = _esAliases
-    msg.send("The cluster alias #{alias} for #{url} has been added to the brain")
+    clearCache msg, msg.match[1], (text) ->
+      msg.send(text)

#   Get ElasticSearch Cluster Information
#
# 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

          list   = [header].concat(lines.sort().reverse()).join("\n")
          msg.send("/code #{list}")

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

    if cluster_url == "" || cluster_url == undefined
      msg.send("No ES Cluster found for #{alias}")
    else
      msg.send("Clearing the cache for the cluster: #{cluster_url}")
      msg.http("#{cluster_url}/_cache/clear")
        .post() (err, res, body) ->
          json = JSON.parse(body)
          shards = json['_shards']['total']
          successful = json['_shards']['successful']
          failure = json['_shards']['failed']
          msg.send "Total Shards: #{shards} \n Successful: #{successful} \n Failure: #{failure}"

  showAliases = (msg) ->

    if _esAliases == null
      msg.send("I cannot find any ElasticSearch Cluster aliases")
    else
      for alias of _esAliases
        msg.send("I found '#{alias}' as an alias for the cluster: #{_esAliases[alias]}")

  clearAlias = (msg, alias) ->
    delete _esAliases[alias]
    robot.brain.data.elasticsearch_aliases = _esAliases
    msg.send("The cluster alias #{alias} has been removed")

  setAlias = (msg, alias, url) ->
    _esAliases[alias] = url
    robot.brain.data.elasticsearch_aliases = _esAliases
    msg.send("The cluster alias #{alias} for #{url} has been added to the brain")

  robot.hear /elasticsearch cat nodes (.*)/i, (msg) ->
    if msg.message.user.id is robot.name
      return
