Elasticsearch 的基本删除方法

import com.sun.xml.internal.bind.v2.TODO;

import java.io.IOException;
import java.util.*;


import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.IdsQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.work.util.PageUtil;

import redis.RedisUtil;

@Controller
@RequestMapping(value = "base/BaseLog")
public class BaseLogController {

	@Autowired
	private RestHighLevelClient rhlClient;

	@Autowired
	private RedisUtil redisUtil;

	
	/**
	 *
	 * @Description: TODO  elasticSearch的基本删除方法
	 * @param
	 * @return
	 * @throws
	 * @author pengbin
	 * 2018/2/27 16:14
	 */
    @RequestMapping(value = "TestEsDelete", method = RequestMethod.POST)
    public void TestEsDelete() {
        System.out.println("ok");

        //通过id删除分别需要三个参数:index,type,以及id
        DeleteRequest deleteRequest = new DeleteRequest("my_project-2018.02.27","doc","p0_w1WEBduW1QBK2RVV4");
        DeleteResponse response = null;
        try {
            response = rhlClient.delete(deleteRequest);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(response);
    }
}
其他参考资料:
ElasticSearch RestHighLevelClient 教程(三) 删除&&查询删除
http://blog.youkuaiyun.com/paditang/article/details/79172837

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值