本文整理了Java中org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse.isAcknowledged()
方法的一些代码示例,展示了DeleteIndexResponse.isAcknowledged()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DeleteIndexResponse.isAcknowledged()
方法的具体详情如下:
包路径:org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse
类名称:DeleteIndexResponse
方法名:isAcknowledged
暂无
代码示例来源:origin: SonarSource/sonarqube
private static void deleteIndexIfExists(String name) {
try {
DeleteIndexResponse response = SHARED_NODE.client().admin().indices().prepareDelete(name).get();
checkState(response.isAcknowledged(), "Fail to drop the index " + name);
} catch (IndexNotFoundException e) {
// ignore
}
}
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
public static void assertAcked(DeleteIndexResponse response) {
assertThat("Delete Index failed - not acked", response.isAcknowledged(), equalTo(true));
assertVersionSerializable(response);
}
代码示例来源:origin: com.netflix.raigad/raigad
/**
* Courtesy Jae Bae
*/
public void deleteIndices(Client client, String indexName, int timeout) {
logger.info("trying to delete " + indexName);
DeleteIndexResponse deleteIndexResponse = client.admin().indices().prepareDelete(indexName).execute().actionGet(timeout);
if (!deleteIndexResponse.isAcknowledged()) {
throw new RuntimeException("INDEX DELETION FAILED");
} else {
logger.info(indexName + " deleted");
}
}
代码示例来源:origin: javanna/elasticshell
@Override
protected XContentBuilder toXContent(DeleteIndexRequest request, DeleteIndexResponse response, XContentBuilder builder) throws IOException {
return builder.startObject()
.field(Fields.OK, true)
.field(Fields.ACKNOWLEDGED, response.isAcknowledged())
.endObject();
}
}
代码示例来源:origin: jaibeermalik/searchanalytics-bigdata
@Override
public boolean deleteIndex(final String indexName) {
return searchClientService.getClient().admin().indices()
.prepareDelete(indexName).execute().actionGet()
.isAcknowledged();
}
代码示例来源:origin: arey/spring-batch-toolkit
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) {
try {
DeleteIndexResponse response = esClient.admin().indices().prepareDelete(indexName).execute().actionGet();
if (!response.isAcknowledged()) {
throw new RuntimeException("Index deletion has not been acknowledged");
}
LOG.info("Index {} deleted", indexName);
} catch (IndexNotFoundException e) {
LOG.info("The index {} does not exist. Thus nothing to delete.", indexName);
}
return RepeatStatus.FINISHED;
}
代码示例来源:origin: souyunku/SpringBootExamples
/**
* 删除索引
*
* @param index
* @return
*/
public static boolean deleteIndex(String index) {
if (!isIndexExist(index)) {
LOGGER.info("Index is not exits!");
}
DeleteIndexResponse dResponse = client.admin().indices().prepareDelete(index).execute().actionGet();
if (dResponse.isAcknowledged()) {
LOGGER.info("delete index " + index + " successfully!");
} else {
LOGGER.info("Fail to delete index " + index);
}
return dResponse.isAcknowledged();
}
代码示例来源:origin: jaibeermalik/elasticsearch-tutorial
@Override
public boolean deleteIndex(String indexName)
{
return searchClientService.getClient().admin().indices().prepareDelete(indexName).execute().actionGet().isAcknowledged();
}
代码示例来源:origin: tlrx/elasticsearch-test
/**
* Delete an index
*
* @param context
* @param nodeName
* @param indexName
* @throws ElasticsearchException
* @throws Exception
*/
private void deleteIndex(Map<String, Object> context, String nodeName, String indexName) throws ElasticsearchException, Exception {
DeleteIndexResponse response = admin(context, nodeName).indices().prepareDelete(indexName).execute().actionGet();
if (!response.isAcknowledged()) {
throw new Exception("Could not delete index [" + indexName + "]");
}
}
代码示例来源:origin: com.github.tlrx/elasticsearch-test
/**
* Delete an index
*
* @param context
* @param nodeName
* @param indexName
* @throws ElasticsearchException
* @throws Exception
*/
private void deleteIndex(Map<String, Object> context, String nodeName, String indexName) throws ElasticsearchException, Exception {
DeleteIndexResponse response = admin(context, nodeName).indices().prepareDelete(indexName).execute().actionGet();
if (!response.isAcknowledged()) {
throw new Exception("Could not delete index [" + indexName + "]");
}
}
代码示例来源:origin: Anchormen/sql4es
/**
* Deletes the INDEX with the specified name
* @param sql
* @param drop
* @return
* @throws SQLException
*/
public int execute(String sql, DropTable drop) throws SQLException {
String index = drop.getTableName().toString();
index = Heading.findOriginal(sql.trim()+";", index, "table\\s+",";");
DeleteIndexResponse response = client.admin().indices().prepareDelete(index).execute().actionGet();
if(!response.isAcknowledged()) throw new SQLException("Elasticsearch failed to delete the specified index");
return 0;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public synchronized void deleteIndex() {
DeleteIndexResponse response = client.admin().indices().delete(new DeleteIndexRequest(index)).actionGet();
if (!response.isAcknowledged()) {
throw new RuntimeException("cannot delete index " + index);
}
client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
}
代码示例来源:origin: dqeasycloud/easy-cloud
@Override
public boolean deleteIndex(String indexName) {
Assert.notNull(indexName, "No index defined for delete operation");
if (indexExists(indexName)) {
return getIndicesAdminClient().delete(new DeleteIndexRequest(indexName)).actionGet().isAcknowledged();
}
return false;
}
代码示例来源:origin: ozlerhakan/mongolastic
@Override
public void dropDataSet() {
final String indexName = config.getMisc().getDindex().getAs();
IndicesAdminClient admin = client.getClient().admin().indices();
IndicesExistsRequestBuilder builder = admin.prepareExists(indexName);
if (builder.execute().actionGet().isExists()) {
DeleteIndexResponse delete = admin.delete(new DeleteIndexRequest(indexName)).actionGet();
if (delete.isAcknowledged())
logger.info(String.format("The current index %s was deleted.", indexName));
else
logger.info(String.format("The current index %s was not deleted.", indexName));
}
}
代码示例来源:origin: eclipse/kapua
@Override
public void deleteIndexes(String... indexes) throws ClientException {
final DeleteIndexRequest request = DeleteIndexAction.INSTANCE.newRequestBuilder(esClientProvider.getClient()).request();
for (String index : indexes) {
request.indices(index);
try {
logger.debug("Deleting index {}", index);
DeleteIndexResponse deleteResponse = esClientProvider.getClient().admin().indices().delete(request).actionGet(getQueryTimeout());
if (!deleteResponse.isAcknowledged()) {
throw new ClientException(ClientErrorCodes.ACTION_ERROR, CLIENT_CANNOT_DELETE_INDEX_ERROR_MSG);
}
logger.debug("Deleting index {} DONE", index);
} catch (IllegalStateException e) {
throw new ClientException(ClientErrorCodes.ACTION_ERROR, e, CLIENT_CANNOT_DELETE_INDEX_ERROR_MSG);
} catch (IndexNotFoundException e) {
// do nothing it's not an error
// switch the log level to debug?
logger.debug("Deleting index {} : index does not exist!", index);
}
}
}
代码示例来源:origin: dqeasycloud/easy-cloud
public boolean deleteIndex(String indexName, String type) throws IOException {
try {
DeleteIndexRequest request = new DeleteIndexRequest("posts");
DeleteIndexResponse deleteIndexResponse = client.indices().delete(request);
/*restHighLevelClient.indices().deleteAsync(request, new ActionListener<DeleteIndexResponse>() {
@Override
public void onResponse(DeleteIndexResponse deleteIndexResponse) {
}
@Override
public void onFailure(Exception e) {
}
});*/
return deleteIndexResponse.isAcknowledged();
} catch (ElasticsearchException exception) {
if (exception.status() == RestStatus.NOT_FOUND) {
}
}
return false;
}
代码示例来源:origin: org.eclipse.kapua/kapua-datastore-client-transport
@Override
public void deleteAllIndexes() throws ClientException {
final DeleteIndexRequest request = DeleteIndexAction.INSTANCE.newRequestBuilder(esClientProvider.getClient()).request();
request.indices(INDEXES_ALL);
try {
DeleteIndexResponse deleteResponse = esClientProvider.getClient().admin().indices().delete(request).actionGet(getQueryTimeout());
if (!deleteResponse.isAcknowledged()) {
throw new ClientException(ClientErrorCodes.ACTION_ERROR, CLIENT_CANNOT_DELETE_INDEX_ERROR_MSG);
}
} catch (IllegalStateException e) {
throw new ClientException(ClientErrorCodes.ACTION_ERROR, e, CLIENT_CANNOT_DELETE_INDEX_ERROR_MSG);
}
}
代码示例来源:origin: eclipse/kapua
@Override
public void deleteAllIndexes() throws ClientException {
final DeleteIndexRequest request = DeleteIndexAction.INSTANCE.newRequestBuilder(esClientProvider.getClient()).request();
request.indices(INDEXES_ALL);
try {
DeleteIndexResponse deleteResponse = esClientProvider.getClient().admin().indices().delete(request).actionGet(getQueryTimeout());
if (!deleteResponse.isAcknowledged()) {
throw new ClientException(ClientErrorCodes.ACTION_ERROR, CLIENT_CANNOT_DELETE_INDEX_ERROR_MSG);
}
} catch (IllegalStateException e) {
throw new ClientException(ClientErrorCodes.ACTION_ERROR, e, CLIENT_CANNOT_DELETE_INDEX_ERROR_MSG);
}
}
代码示例来源:origin: apache/apex-malhar
@After
public void cleanup() throws IOException
{
try {
DeleteIndexResponse delete = store.client.admin().indices().delete(new DeleteIndexRequest(INDEX_NAME)).actionGet();
if (!delete.isAcknowledged()) {
logger.error("Index wasn't deleted");
}
store.disconnect();
} catch (NoNodeAvailableException e) {
//This indicates that elasticsearch is not running on a particular machine.
//Silently ignore in this case.
}
}
}
代码示例来源:origin: apache/streams
@BeforeClass
public void prepareTestPersistWriter() throws Exception {
testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration("ElasticsearchPersistWriterIT");
testClient = ElasticsearchClientManager.getInstance(testConfiguration).client();
ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);
IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex());
IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
if(indicesExistsResponse.isExists()) {
DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getIndex());
DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet();
assertTrue(deleteIndexResponse.isAcknowledged());
}
}
内容来源于网络,如有侵权,请联系作者删除!