本文整理汇总了Java中org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse.isAcknowledged方法的典型用法代码示例。如果您正苦于以下问题:Java DeleteIndexResponse.isAcknowledged方法的具体用法?Java DeleteIndexResponse.isAcknowledged怎么用?Java DeleteIndexResponse.isAcknowledged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse
的用法示例。
在下文中一共展示了DeleteIndexResponse.isAcknowledged方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
/**
* Delete an index in Elasticsearch.
*
* @param indexName
*
* @return true if the request was acknowledged.
*/
public static boolean delete(String indexName) {
synchronized (Indices.class) {
try {
DeleteIndexResponse response = self.client.getClient().admin().indices().delete(new DeleteIndexRequest(indexName)).get();
if (response.isAcknowledged()) {
self.indexCache.remove(indexName);
return true;
} else {
return false;
}
} catch (InterruptedException|ExecutionException e) {
log.error("Error while deleting index", e);
return false;
}
}
}
示例2: cleanup
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
@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.
}
}
示例3: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
/**
*
*/
private boolean deleteIndex(String indexName) {
boolean val = false;
try {
DeleteIndexResponse deleteResponse = this.client.admin().indices().delete(new DeleteIndexRequest(indexName)).actionGet();
if (deleteResponse.isAcknowledged()) {
logger.info("Index {} deleted", indexName);
val = true;
} else {
logger.error("Could not delete index " + indexName);
}
} catch (IndexNotFoundException e) {
logger.info("Index " + indexName + " not found.");
}
return val;
}
示例4: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
/**
* This method will delete the index
*
* @param index String name of the index which we need to delete.
* @return boolean
*/
public static boolean deleteIndex(String index) {
boolean response = false;
DeleteIndexResponse deleteResponse = ConnectionManager.getClient().admin().indices()
.prepareDelete(index).get();
if (deleteResponse != null && deleteResponse.isAcknowledged()) {
response = true;
}
return response;
}
示例5: clear
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
@Override
public void clear(Handler<AsyncResult<Void>> handler) {
DeleteIndexResponse response = client.admin()
.indices()
.delete(new DeleteIndexRequest(context.database()))
.actionGet();
if (response.isAcknowledged()) {
client.admin().indices().refresh(new RefreshRequest(context.database()));
handler.handle(result());
context.onCollectionDropped();
} else {
handler.handle(error(new StorageFailureException()));
}
}
示例6: execute
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
/**
* 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;
}
示例7: createIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
private void createIndex() throws Exception {
boolean exists = client.admin().indices().prepareExists(mIndex).execute().actionGet().isExists();
if (exists) {
logger.log(Level.INFO, "Preexisting index " + mIndex + " will be removed.");
DeleteIndexResponse deleteResponse = client.admin().indices().delete(new DeleteIndexRequest(mIndex)).actionGet();
if (deleteResponse.isAcknowledged()) {
logger.log(Level.INFO, "Preexisting index " + mIndex + " successfully removed.");
exists = false;
}
}
logger.log(Level.INFO, "Index " + mIndex + " will be created.");
String docMapping = new String(Files.readAllBytes(Paths.get(documentMappingFile)));
XContentBuilder builder = XContentFactory.jsonBuilder();
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
.createParser(docMapping.getBytes());
parser.close();
builder.copyCurrentStructure(parser);
CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(mIndex);
createIndexRequestBuilder.addMapping(DOCUMENT_TYPE, builder);
createIndexRequestBuilder.execute().actionGet();
}
示例8: clear
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
@Override
public boolean clear(MappingConfiguration mapping) {
log.info("Deleting index '{}'", mapping.getIndex());
DeleteIndexRequest request = new DeleteIndexRequest(mapping.getIndex());
try {
DeleteIndexResponse delete = getClient().admin().indices().delete(request).actionGet();
log.info("Delete acknowledged: {}", delete.isAcknowledged());
return delete.isAcknowledged();
} catch (Exception e) {
log.info("Index does not exist, no need to delete: {}", e.getMessage());
return true;
}
}
示例9: dropDataSet
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
@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));
}
}
示例10: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的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();
}
示例11: truncate
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
@Override
public void truncate() {
IndicesExistsResponse indicesExistsResponse = client.admin().indices().prepareExists(indexName + "*").execute().actionGet();
if (indicesExistsResponse.isExists()) {
DeleteIndexResponse response = client.admin().indices().prepareDelete(indexName + "*").execute().actionGet();
if (!response.isAcknowledged()) {
System.err.println("Index wasn't deleted");
}
}
}
示例12: deleteAllIndices
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
public void deleteAllIndices(String backendId) {
String[] indices = toIndices(backendId);
if (indices != null && indices.length > 0) {
DeleteIndexResponse deleteIndexResponse = internalClient.admin().indices().prepareDelete(indices).get();
if (!deleteIndexResponse.isAcknowledged())
throw Exceptions.runtime(//
"backend [%s] deletion not acknowledged by the whole cluster", //
backendId);
}
}
示例13: deleteAll
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
public void deleteAll() {
//there is no Java api to delete by query, so use admin
try {
DeleteIndexResponse delete = client.admin().indices().delete(new DeleteIndexRequest(esIndex)).actionGet();
if (!delete.isAcknowledged()) {
log.error("Index wasn't deleted");
}
} catch (IndexNotFoundException e) {
//no problem, ignore it
}
//we use this operation to setup needed mappings for next adds too. This is somewhat customized for how DIH works
//now we create the index again
createIndex();
}
示例14: deleteIndices
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
void deleteIndices(Client client, String indexName, int timeout) {
DeleteIndexResponse deleteIndexResponse = client.admin().indices().prepareDelete(indexName).execute().actionGet(timeout);
if (deleteIndexResponse.isAcknowledged()) {
logger.info(indexName + " deleted");
} else {
logger.warn("Failed to delete " + indexName);
throw new RuntimeException("Failed to delete " + indexName);
}
}
示例15: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; //导入方法依赖的package包/类
public DeleteIndexResponse deleteIndex(final String index,
final BuilderCallback<DeleteIndexRequestBuilder> builder) {
final DeleteIndexResponse actionGet = builder
.apply(client().admin().indices().prepareDelete(index))
.execute().actionGet();
if (!actionGet.isAcknowledged()) {
onFailure("Failed to create " + index + ".", actionGet);
}
return actionGet;
}