feat: There is no way the, 重置ES 添加 删除
This commit is contained in:
@@ -28,6 +28,11 @@ public interface ElasticsearchService {
|
||||
*/
|
||||
boolean deleteIndex(String index);
|
||||
|
||||
/**
|
||||
* Elasticsearch 批量删除数据
|
||||
*/
|
||||
void deleteBatchId(List<String> list,String index);
|
||||
|
||||
/**
|
||||
* Elasticsearch 判断索引是否存在定义
|
||||
* @param index 要判断的索引名称
|
||||
|
||||
+15
@@ -8,8 +8,10 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
|
||||
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.get.GetRequestBuilder;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
@@ -178,6 +180,19 @@ public class ElasticsearchServiceImpl implements ElasticsearchService {
|
||||
return response.getResult().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatchId( List<String> lists,String index) {
|
||||
logger.info("批量删除索引: "+index +", 正在删除:" + lists.size() + "条数据");
|
||||
BulkRequest request = new BulkRequest();
|
||||
for (String smsStr : lists) {
|
||||
DeleteRequest deleteRequest=new DeleteRequest(index,smsStr);
|
||||
request.add(deleteRequest);
|
||||
}
|
||||
client.bulk(request);
|
||||
logger.info("批量删除索引: "+index +", 删除成功共:" + lists.size() + "条数据");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Elasticsearch 删除某个index所有的文档接口实现
|
||||
* @param index 要插入的索引
|
||||
|
||||
Reference in New Issue
Block a user