赞
踩
// 测试方法 func (commonES) UpdateOne(ctx context.Context, orgID int, index string, query interface{}) error { params := map[string]interface{}{ "deal_deal_name":"zhangxinzhifa", } script := "ctx._source['deal_deal_name']=params['deal_deal_name']" // str, err := json.Marshal(query) // if err != nil { // return nil // } //res, err := esClient.UpdateByQuery().Index(genESIndex(index, orgID))..Body(string(str)) // queryList := elastic.NewBoolQuery().Must() bool_query := elastic.NewBoolQuery() bool_query.Must(elastic.NewTermQuery("deal_id",10)) bool_query.Must(elastic.NewTermQuery("organization_id",1)) bool_query.Must(elastic.NewTermQuery("is_delete",false)) res, err := esClient.UpdateByQuery().Index(genESIndex(index, orgID)).Query(bool_query). Conflicts("proceed").Type("_doc"). Script(elastic.NewScriptInline(script).Params(params)).Size(9999).Do(ctx) if err != nil { return errors.Wrap(err, "upsert associated failed") } print(res) return nil }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。