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; }
public DeleteByQueryRequestBuilder deleteByQuery(DateRange range, String type) throws NoIndexSelectedException { return index.deleteByQuery(client, range, type); }
public SearchRequestBuilder search(DateRange range, String type) throws NoIndexSelectedException { return index.search(client, range, type); }
public CountRequestBuilder count(DateRange range, String type) throws NoIndexSelectedException { return index.count(client, range, type); }
public String[] writeIndices(DateRange range) throws NoIndexSelectedException { return index.writeIndices(range); }