当前位置: 首页>>代码示例>>Java>>正文


Java DeleteResponse.isNotFound方法代码示例

本文整理汇总了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();
       }
   }
 
开发者ID:yamingd,项目名称:argo,代码行数:27,代码来源:ElasticSearchTemplate.java

示例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);
	}
}
 
开发者ID:macanhhuy,项目名称:dcp-api,代码行数:42,代码来源:ContentRestService.java


注:本文中的org.elasticsearch.action.delete.DeleteResponse.isNotFound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。