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


Java DeleteResponse.getId方法代碼示例

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


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

示例3: deltele

import org.elasticsearch.action.delete.DeleteResponse; //導入方法依賴的package包/類
@Override
public String deltele(String id) {
    DeleteResponse response = transportClient.prepareDelete(index, type, id).get();
    return response.getId();
}
 
開發者ID:jeikerxiao,項目名稱:SpringBootStudy,代碼行數:6,代碼來源:PersonDaoImpl.java


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