code: private boolean createIndex(String index, Map<String, Object> defaultSettings) {
          IndicesExistsResponse res = client.admin().indices().prepareExists(index).execute().actionGet();
          boolean created = false;
          if (!res.isExists()) {
              CreateIndexRequestBuilder req = client.admin().indices().prepareCreate(index);
              req.setSettings(defaultSettings);
              created = req.execute().actionGet().isAcknowledged();
              if (!created) {
                  throw new RuntimeException("Could not create index [" + index + "]");
              }
          }
  
          return created;
      }
docs: Check if index is created. if not it will created it
  
  @param index The index
  @return returns true if it just created the index. False if the index already existed