code: public static void createAlias(RestClient client, String alias, String index) throws Exception {
          logger.trace("createAlias({},{})", alias, index);
  
          assert client != null;
          assert alias != null;
          assert index != null;
  
          Request request = new Request("POST", "/_aliases/");
          request.setJsonEntity("{\"actions\":[{\"add\":{\"index\":\"" + index +"\",\"alias\":\"" + alias +"\"}}]}");
          Response response = client.performRequest(request);
  
          if (response.getStatusLine().getStatusCode() != 200) {
              logger.warn("Could not create alias [{}] on index [{}]", alias, index);
              throw new Exception("Could not create alias ["+alias+"] on index ["+index+"].");
          }
          logger.trace("/createAlias({},{})", alias, index);
      }
docs: Create an alias if needed
  @param client Client to use
  @param alias Alias name
  @param index Index name
  @throws Exception When alias can not be set