Delete - TuPengXiong/TuPengXiong.github.io GitHub Wiki

package tpx.elasticsearch;

import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.transport.TransportClient;

public class Delete {

	public static void main(String[] args) {
		Delete Delete = new Delete();
		Index index = new Index();
		index.createTransportClient();
		DeleteResponse response = Delete.prepareDeleteResponse(index.client,"tpx", "testBuilder", "1");
		printResponse(response);
	
		Get get = new Get();
		get.printResponse(get.getResponse(index.client,"tpx", "testBuilder", "1"));
		
		index.closeTransportClient();
	}
	
	public DeleteResponse prepareDeleteResponse(TransportClient client,String index,String shard,String id){
		DeleteResponse response = client.prepareDelete(index, shard, id).get();
		return response;
	}
	
	public static void printResponse(DeleteResponse response){
		System.out.println(response.getIndex());
	}
}