Get API,其实就是用于获取单个索引的接口。来,话不多说,直接上代码:
GetResponse response = client.prepareGet("twitter", "tweet", "1") .execute() .actionGet();
代码区:twitter为索引,tweet为类型,1为索引ID。
多线程下:
GetResponse response = client.prepareGet("twitter", "tweet", "1") .setOperationThreaded(true) .execute() .actionGet();
Delete API,删除单个索引
DeleteResponse response = client.prepareDelete("twitter", "tweet", "1") .execute() .actionGet();
多线程下:
DeleteResponse response = client.prepareDelete("twitter", "tweet", "1") .setOperationThreaded(false) .execute() .actionGet();