當前位置: 首頁>>代碼示例>>Java>>正文


Java DeleteResponse.isFound方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.delete.DeleteResponse.isFound方法的典型用法代碼示例。如果您正苦於以下問題:Java DeleteResponse.isFound方法的具體用法?Java DeleteResponse.isFound怎麽用?Java DeleteResponse.isFound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.delete.DeleteResponse的用法示例。


在下文中一共展示了DeleteResponse.isFound方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processDelete

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
/**
 * Processes a "delete" request.
 * 
 * @param urlItems Items of the URL
 * @return Result of the delete request, it contains the id of the deleted document
 */
private InterpreterResult processDelete(String[] urlItems) {

  if (urlItems.length != 3 
      || StringUtils.isEmpty(urlItems[0]) 
      || StringUtils.isEmpty(urlItems[1]) 
      || StringUtils.isEmpty(urlItems[2])) {
    return new InterpreterResult(InterpreterResult.Code.ERROR,
                                 "Bad URL (it should be /index/type/id)");
  }

  final DeleteResponse response = client
    .prepareDelete(urlItems[0], urlItems[1], urlItems[2])
    .get();
      
  if (response.isFound()) {
    return new InterpreterResult(
      InterpreterResult.Code.SUCCESS,
      InterpreterResult.Type.TEXT,
      response.getId());
  }
      
  return new InterpreterResult(InterpreterResult.Code.ERROR, "Document not found");
}
 
開發者ID:lorthos,項目名稱:incubator-zeppelin-druid,代碼行數:30,代碼來源:ElasticsearchInterpreter.java

示例2: deleteDocById

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
/**
 * 刪除文檔
 * 
 * @param id
 */
public boolean deleteDocById(String docId) {
    try {
        // 刪除
        DeleteResponse resp = ESClient.getClient()
                .prepareDelete(this.currentIndexName, this.indexType.getTypeName(), docId)
                .setOperationThreaded(false).execute().actionGet();
        // 刷新
        ESClient.getClient().admin().indices()
                .refresh(new RefreshRequest(this.currentIndexName)).actionGet();
        if (resp.isFound()) {
            log.warn("delete index sunccess,indexname:{},type:{},delete {} items",
                    this.indexType.getIndexName(), this.indexType.getTypeName(), 1);
            return resp.isFound();
        }
    } catch (Exception e) {
        log.error("delete Doc fail,indexname:{},type:{}", this.indexType.getIndexName(),
                this.indexType.getTypeName());
    }
    return false;
}
 
開發者ID:hailin0,項目名稱:es-service-parent,代碼行數:26,代碼來源:IndexTransaction.java

示例3: deleteDatetimeValue

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
@Override
public boolean deleteDatetimeValue(String spaceKey, String propertyName) {
	String documentName = prepareValueStoreDocumentName(spaceKey, propertyName);

	if (logger.isDebugEnabled())
		logger.debug("Going to delete datetime value from {} property for space {}. Document name is {}.", propertyName,
				spaceKey, documentName);

	refreshSearchIndex(getRiverIndexName());

	DeleteResponse lastSeqGetResponse = client.prepareDelete(getRiverIndexName(), riverName.name(), documentName)
			.execute().actionGet();
	if (!lastSeqGetResponse.isFound()) {
		if (logger.isDebugEnabled()) {
			logger.debug("{} document doesn't exist in remote river persistent store", documentName);
		}
		return false;
	} else {
		return true;
	}

}
 
開發者ID:searchisko,項目名稱:elasticsearch-river-remote,代碼行數:23,代碼來源:RemoteRiver.java

示例4: onResponse

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
@Override
public void onResponse(DeleteResponse response) {
    if (!response.isFound()) {
        result.set(TaskResult.ZERO);
    } else {
        result.set(TaskResult.ONE_ROW);
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:9,代碼來源:ESDeleteTask.java

示例5: remove

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
@Override
public void remove(String workflowId) {
	try {

		DeleteRequest req = new DeleteRequest(indexName, WORKFLOW_DOC_TYPE, workflowId);
		DeleteResponse response = client.delete(req).actionGet();
		if (!response.isFound()) {
			log.error("Index removal failed - document not found by id " + workflowId);
		}
	} catch (Throwable e) {
		log.error("Index removal failed failed {}", e.getMessage(), e);
		Monitors.error(className, "remove");
	}
}
 
開發者ID:Netflix,項目名稱:conductor,代碼行數:15,代碼來源:ElasticSearchDAO.java

示例6: delete

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
@Override
public void delete(String id) throws StorageException {
    DeleteResponse response = client.prepareDelete(index, type, id)
            .execute()
            .actionGet();

    if (!response.isFound()) {
        throw new NotFoundException("Unable to delete entity with id " + id + " (not found)");
    }
}
 
開發者ID:Ingensi,項目名稱:storeit,代碼行數:11,代碼來源:ElasticsearchStorage.java

示例7: delete

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
public boolean delete(String backendId, String type, String id, boolean refresh, boolean throwNotFound) {
	DeleteResponse response = internalClient.prepareDelete(//
			toAlias(backendId, type), type, id).setRefresh(refresh).get();

	if (response.isFound())
		return true;
	if (throwNotFound)
		throw Exceptions.notFound(backendId, type, id);

	return false;
}
 
開發者ID:spacedog-io,項目名稱:spacedog-server,代碼行數:12,代碼來源:ElasticClient.java

示例8: delete

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
@Override
public <T extends Indexable> boolean delete(final T document, String index, String type) throws ArchiveException {
    try {
        final DeleteResponse response = client.prepareDelete(index, type, document.getDocumentId())
                .setRefresh(true)
                .execute()
                .actionGet();
        return response.isFound();
    } catch (Exception ex) {
        log.log(Level.SEVERE, "Delete went wrong: " + ex.getMessage());
        ex.printStackTrace();
        throw new ArchiveException("Delete went wrong: " + ex.getMessage());
    }
}
 
開發者ID:whalebone,項目名稱:sinkit-core,代碼行數:15,代碼來源:ElasticNativeServiceEJB.java

示例9: deleteDocumentWithParams

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
@Override
protected void deleteDocumentWithParams(Map<String, Object> deleteParams) {
    final DeleteRequestBuilder deleteRequestBuilder = prepareDeleteDocument(deleteParams);
    final DeleteResponse deleteResponse = deleteDocumentWithRequest(deleteRequestBuilder);
    if (getLog().isDebugEnabled()) {
        if (!deleteResponse.isFound()) {
            getLog().debug("Could not delete doc with by id: " + deleteParams.get(DELETE_RESOURCE_KEY_ITEM)
                    + " in index builder [" + getName() + "] because the document wasn't found");
        } else {
            getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder ["
                    + getName() + "]");
        }
    }
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:15,代碼來源:QuestionElasticSearchIndexBuilder.java

示例10: executeBulkRequest

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
protected void executeBulkRequest(BulkRequestBuilder bulkRequest) {
    BulkResponse bulkResponse = bulkRequest.execute().actionGet();

    getLog().info("Bulk request of batch size: " + bulkRequest.numberOfActions() + " took "
            + bulkResponse.getTookInMillis() + " ms in index builder: " + getName());

    for (BulkItemResponse response : bulkResponse.getItems()) {
        if (response.getResponse() instanceof DeleteResponse) {
            DeleteResponse deleteResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem deleting doc: " + response.getId() + " in index builder: " + getName()
                        + " error: " + response.getFailureMessage());
            } else if (!deleteResponse.isFound()) {
                getLog().debug("ES could not find a doc with id: " + deleteResponse.getId()
                        + " to delete in index builder: " + getName());
            } else {
                getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder: "
                        + getName());
            }
        } else if (response.getResponse() instanceof IndexResponse) {
            IndexResponse indexResponse = response.getResponse();

            if (response.isFailed()) {
                getLog().error("Problem updating content for doc: " + response.getId() + " in index builder: "
                        + getName() + " error: " + response.getFailureMessage());
            } else {
                getLog().debug("ES indexed content for doc with id: " + indexResponse.getId()
                        + " in index builder: " + getName());
            }
        }
    }
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:34,代碼來源:BaseElasticSearchIndexBuilder.java

示例11: deleteDocumentWithParams

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
protected void deleteDocumentWithParams(Map<String, Object> deleteParams) {
    final DeleteRequestBuilder deleteRequestBuilder = prepareDeleteDocument(deleteParams);
    final DeleteResponse deleteResponse = deleteDocumentWithRequest(deleteRequestBuilder);

    if (getLog().isDebugEnabled()) {
        if (!deleteResponse.isFound()) {
            getLog().debug("Could not delete doc with by id: " + deleteParams.get(DELETE_RESOURCE_KEY_DOCUMENT_ID)
                    + " in index builder [" + getName() + "] because the document wasn't found");
        } else {
            getLog().debug("ES deleted a doc with id: " + deleteResponse.getId() + " in index builder ["
                    + getName() + "]");
        }
    }
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:15,代碼來源:BaseElasticSearchIndexBuilder.java

示例12: deleteAlert

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
public boolean deleteAlert(String term) {
    DeleteResponse response = ElasticsearchConnectionManager.getClient()
            .prepareDelete(ALERT_INDEX, PERCOLATOR_TYPE, term)
            .execute()
            .actionGet();
    return response.isFound();
}
 
開發者ID:txtData,項目名稱:socialradar,代碼行數:8,代碼來源:AlertManager.java

示例13: deleteIndex

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
/**
 * 僅僅隻刪除索引
 * @param index
 * @param type
 * @param id
 */
private static void deleteIndex(String index, String type, String id){
	Client client = createTransportClient();
	DeleteResponse response = client.prepareDelete(index, type, id)
			.execute()
			.actionGet();
	boolean isFound = response.isFound();
	System.out.println("索引是否 存在:"+isFound); // 發現doc已刪除則返回true
	System.out.println("****************index ***********************");
	// Index name
	String _index = response.getIndex();
	// Type name
	String _type = response.getType();
	// Document ID (generated or not)
	String _id = response.getId();
	// Version (if it's the first time you index this document, you will get: 1)
	long _version = response.getVersion();
	System.out.println(_index+","+_type+","+_id+","+_version);
	
	//優化索引
	OptimizeRequest optimizeRequest = new OptimizeRequest(index);
    OptimizeResponse optimizeResponse = client.admin().indices().optimize(optimizeRequest).actionGet();
    System.out.println(optimizeResponse.getTotalShards()+","+optimizeResponse.getSuccessfulShards()+","+optimizeResponse.getFailedShards());
    
    //刷新索引
	FlushRequest flushRequest = new FlushRequest(index);
	flushRequest.force(true);
	FlushResponse flushResponse = client.admin().indices().flush(flushRequest).actionGet();
	System.out.println(flushResponse.getTotalShards()+","+flushResponse.getSuccessfulShards()+","+flushResponse.getFailedShards());
	
}
 
開發者ID:ameizi,項目名稱:elasticsearch-jest-example,代碼行數:37,代碼來源:TransportClient.java

示例14: deleteDocumentBoard

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
public void deleteDocumentBoard(String id) {
	DeleteResponse response = client.prepareDelete()
			.setIndex(elasticsearchProperties.getIndexBoard())
			.setType(Constants.ES_TYPE_ARTICLE)
			.setId(id)
			.get();

	if (! response.isFound())
		log.info("board id {} is not found. so can't delete it!", id);
}
 
開發者ID:JakduK,項目名稱:jakduk-api,代碼行數:11,代碼來源:SearchService.java

示例15: deleteDocumentBoardComment

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
public void deleteDocumentBoardComment(String id) {

		DeleteResponse response = client.prepareDelete()
				.setIndex(elasticsearchProperties.getIndexBoard())
				.setType(Constants.ES_TYPE_COMMENT)
				.setId(id)
				.get();

		if (! response.isFound())
			log.info("comment id {} is not found. so can't delete it!", id);
	}
 
開發者ID:JakduK,項目名稱:jakduk-api,代碼行數:12,代碼來源:SearchService.java


注:本文中的org.elasticsearch.action.delete.DeleteResponse.isFound方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。