elasticsearch,Python,elasticsearch" /> elasticsearch,Python,elasticsearch" />

Python 更新多个文档

Python 更新多个文档,python,elasticsearch,Python,elasticsearch,我想在elasticsearch中更新多个文档。 更新应该与SQL查询相对应 UPDATE tablename SET expired=true where id not in (list_of_ids) 是否可能,或者您是否建议使用不同的解决方案来跟踪活动文档和非活动文档 我想保留和使用非活动文档进行统计 谢谢这可以用轻松完成,如下所示: POST index/_update_by_query { "script": { "inline": "ctx._source.expire

我想在elasticsearch中更新多个文档。 更新应该与SQL查询相对应

UPDATE tablename SET expired=true where id not in (list_of_ids)
是否可能,或者您是否建议使用不同的解决方案来跟踪活动文档和非活动文档

我想保留和使用非活动文档进行统计


谢谢

这可以用轻松完成,如下所示:

POST index/_update_by_query
{
  "script": {
    "inline": "ctx._source.expired = true"
  },
  "query": {
    "bool": {
      "must_not": {
        "ids": {
          "values": [1, 2, 3, 4]
        }
      }
    }
  }
}

谢谢,这就是解决办法。在使用elasticsearch的Python中,我只需执行
es.updateby\u查询(index,doctype,body)
其中body是您提供的json。。