elasticSearch elk kibana _update_by_query 批量修改字段值

发布时间 2023-09-08 16:03:44作者: 风中有朵云做的鱼
  
-- 根据多个条件条件 批量修改字段属性 update  elk  ctx._source.xxx 是修改字段的固定写法

POST saas_index/_update_by_query
{
  "script": {
    "source": "ctx._source.marketable='false';",
    "lang": "painless"
  },
  "query": {
  
  
     "bool": { 
      "must": [
        { "match": { "cat_id":   "1" }},
        { "match": { "store_id": "472" }}
      ]
     }
  }

}

-- 根据id  批量修改字段属性 update  elk    ctx._source.xxx 是修改字段的固定写法  xxx是需要修改的字段


POST test_index/_update_by_query
{
  "script": {
    "source": "ctx._source.marketable='false';",
    "lang": "painless"
  },
  "query": {
    "term": {
      "goods_id": {
        "value": "123126637551"
      }
    }
  }

}


 
}
-- 删除指定字段

POST test_index/_update_by_query
{
"script":{
"lang":"painless",
"inline":"ctx._source.remove(\"dept_name\")"
}