|
@@ -646,11 +646,15 @@ func (es *ESClient) Update(indexName string, id int, doc interface{}) bool {
|
|
|
|
|
|
|
|
|
|
|
|
-func (es *ESClient) Delete(indexName string, id int) bool {
|
|
|
- req := esapi.DeleteRequest{
|
|
|
- Index: indexName,
|
|
|
- DocumentID: strconv.Itoa(id),
|
|
|
- Refresh: "true",
|
|
|
+func (es *ESClient) Delete(indexName string, query interface{}) bool {
|
|
|
+ jsonQuery, _ := json.Marshal(query)
|
|
|
+ refresh := new(bool)
|
|
|
+ *refresh = true
|
|
|
+ logger.Info("查询语句: %s", string(jsonQuery))
|
|
|
+ req := esapi.DeleteByQueryRequest{
|
|
|
+ Index: []string{indexName},
|
|
|
+ Body: strings.NewReader(string(jsonQuery)),
|
|
|
+ Refresh: refresh,
|
|
|
}
|
|
|
res, err := req.Do(context.Background(), es.es())
|
|
|
defer res.Body.Close()
|