本文整理汇总了Java中org.elasticsearch.action.delete.DeleteResponse.isNotFound方法的典型用法代码示例。如果您正苦于以下问题:Java DeleteResponse.isNotFound方法的具体用法?Java DeleteResponse.isNotFound怎么用?Java DeleteResponse.isNotFound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.delete.DeleteResponse
的用法示例。
在下文中一共展示了DeleteResponse.isNotFound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.elasticsearch.action.delete.DeleteResponse; //导入方法依赖的package包/类
/**
* 删除索引.
* http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete.html
* @param typeName
* @param id
* @return
*/
public boolean delete(String typeName, String id) throws SearchException {
Timer.Context timer = searchMetrics.indexTimer(typeName, "delId");
try {
DeleteRequestBuilder deleter = client.prepareDelete(indexName,
typeName, id);
DeleteResponse actionGet = deleter.execute().actionGet();
searchMetrics.indexIncr(typeName, "delId");
if (!actionGet.isNotFound()) {
return true;
}
return false;
} catch (Exception e) {
searchMetrics.failedIncr(typeName, "delId", e);
logger.error("delete index Error. ", e);
throw new SearchException("delete index Error. typeName="+typeName+", id="+id, e);
}finally {
timer.stop();
}
}
示例2: deleteContent
import org.elasticsearch.action.delete.DeleteResponse; //导入方法依赖的package包/类
@DELETE
@Path("/{contentId}")
@ProviderAllowed
public Object deleteContent(@PathParam("type") String type, @PathParam("contentId") String contentId,
@QueryParam("ignore_missing") String ignoreMissing) {
// validation
if (contentId == null || contentId.isEmpty()) {
return createRequiredFieldResponse("contentId");
}
if (type == null || type.isEmpty()) {
return createRequiredFieldResponse("type");
}
try {
Map<String, Object> provider = providerService.findProvider(getProvider());
Map<String, Object> typeDef = ProviderService.extractContentType(provider, type);
if (typeDef == null) {
return createBadFieldDataResponse("type");
}
String dcpContentId = providerService.generateDcpId(type, contentId);
if (ProviderService.extractPersist(typeDef)) {
contentPersistenceService.delete(dcpContentId, type);
}
String indexName = ProviderService.extractIndexName(typeDef, type);
String indexType = ProviderService.extractIndexType(typeDef, type);
DeleteResponse dr = searchClientService.getClient().prepareDelete(indexName, indexType, dcpContentId).execute()
.actionGet();
if (dr.isNotFound() && !Boolean.parseBoolean(ignoreMissing)) {
return Response.status(Status.NOT_FOUND).entity("Content not found to be deleted.").build();
} else {
return Response.ok("Content deleted successfully.").build();
}
} catch (Exception e) {
return createErrorResponse(e);
}
}