Example #1
0
  public AsyncFuture<Void> configure() {
    final IndicesAdminClient indices = client.admin().indices();

    log.info("[{}] updating template for {}", templateName, index.template());

    final PutIndexTemplateRequestBuilder put = indices.preparePutTemplate(templateName);

    put.setSettings(settings);
    put.setTemplate(index.template());

    for (final Map.Entry<String, Map<String, Object>> mapping : mappings.entrySet()) {
      put.addMapping(mapping.getKey(), mapping.getValue());
    }

    final ResolvableFuture<Void> future = async.future();

    final ListenableActionFuture<PutIndexTemplateResponse> target = put.execute();

    target.addListener(
        new ActionListener<PutIndexTemplateResponse>() {
          @Override
          public void onResponse(final PutIndexTemplateResponse response) {
            if (!response.isAcknowledged()) {
              future.fail(new Exception("request not acknowledged"));
              return;
            }

            future.resolve(null);
          }

          @Override
          public void onFailure(Throwable e) {
            future.fail(e);
          }
        });

    future.onCancelled(() -> target.cancel(false));
    return future;
  }
Example #2
0
 public DeleteByQueryRequestBuilder deleteByQuery(DateRange range, String type)
     throws NoIndexSelectedException {
   return index.deleteByQuery(client, range, type);
 }
Example #3
0
 public SearchRequestBuilder search(DateRange range, String type) throws NoIndexSelectedException {
   return index.search(client, range, type);
 }
Example #4
0
 public CountRequestBuilder count(DateRange range, String type) throws NoIndexSelectedException {
   return index.count(client, range, type);
 }
Example #5
0
 public String[] writeIndices(DateRange range) throws NoIndexSelectedException {
   return index.writeIndices(range);
 }