Exemplo n.º 1
0
  @Before
  public void before() {
    try {
      if (!clientTemplate.indexExists()) {
        logger.warn("index is not exists!");

        clientTemplate.executeGet(
            new NodeCallback<CreateIndexResponse>() {
              @Override
              public ActionFuture<CreateIndexResponse> execute(final IndicesAdminClient admin) {
                return admin.create(Requests.createIndexRequest(clientTemplate.getIndexName()));
              }
            });
      }
      logger.info("index exists!");
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }
  }