package web_hook import ( "eta/eta_mini_ht_api/common/component/es" "eta/eta_mini_ht_api/controllers" "strings" ) type ESController struct { controllers.WebHookController } func elastic() *es.ESClient { return es.GetInstance() } type DeleteIndex struct { IndexName string `json:"indexName"` Source string `json:"source"` Ids string `json:"ids"` } // DeleteEsData 删除es数据 // @Summary 删除es数据 // @Description 删除es数据 // @Success 200 {object} controllers.BaseResponse // @router /es/delete/ [post] func (h *ESController) DeleteEsData() { controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) { result = h.InitWrapData("删除成功") req := new(DeleteIndex) h.GetPostParams(req) //ids := []int{10605, 10636, 10637, 10638, 10648, 10794, 10839, 10899, 10903, 11002, 11082, 11127, 11276, 11277, 11279, 11280, 11281, 11283, 11284, 11285, 11286, 11287, 11288, 11290, 11291, 11292, 11293, 11303, 11308, 11313, 11314, 11315, 11316, 11321, 11322, 11323, 11328, 11348, 11357, 11395, 11396, 11408, 11409, 11410, 11411, 11419, 11420, 11441, 11452, 11453, 11458, 11459, 11460, 11463, 11464, 11465, 11466, 11474, 11484, 11486, 11487, 11489, 11490, 11494, 11496, 11500, 11501, 11502, 11504, 11505, 11510, 11511, 11512, 11513, 11514, 11517, 11518, 11519, 11521, 11522, 11523, 11524, 11525, 11528, 11529, 11530, 11531, 11532, 11533, 11534, 11536, 11537, 11540, 11542, 11544, 11545, 11546, 11547, 11548, 11549, 11550, 11551, 11552, 11556, 11558, 11559, 11560, 11561, 11563, 11568, 11569, 11570, 11571, 11574, 11575, 11577, 11579, 11583, 11584, 11589, 11592, 11594, 11600, 11601, 11602, 11603, 11604, 11605, 11606, 11607, 11608, 11609, 11610, 11612, 11613, 11614, 11615, 11616, 11621, 11623, 11624, 11626, 11629, 11630, 11631, 11633, 11634, 11635, 11636, 11639, 11640, 11641, 11642, 11648, 11659, 11660, 11667, 11670, 11671, 11672, 11685, 11687, 11688, 11701, 11705, 11707, 11709, 11710, 11711, 11712, 11713, 11714, 11715, 11716, 11717, 11722, 11724, 11725, 11729, 11730, 11735, 11736, 11737, 11738, 11739, 11741, 11742, 11743} var idsStr []string //for _, id := range req.Ids { // idsStr = append(idsStr, strconv.Itoa(id)) //} idsStr = strings.Split(req.Ids, ",") query := map[string]interface{}{ "query": map[string]interface{}{ "bool": map[string]interface{}{ "must": []map[string]interface{}{ {"match": map[string]interface{}{"source": req.Source}}, }, "must_not": []map[string]interface{}{ {"terms": map[string]interface{}{"_id": idsStr}}, }, }, }, } elastic().Delete(req.IndexName, query) h.SuccessResult("success", nil, result) return }) }