我需要在Elasticsearch中用+1来增加字段'post_count'
例如:对于我来说,当我单击按钮时,post_count需要增加

   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "test_work",
            "_type": "user",
            "_id": "d989dd8629f8b6cc59faf8a1aa2328c8",
            "_score": 1,
            "_source": {
               "first_name": "test",
               "last_name": "amt",
               "post_count":0
            }
         }
      ]

是否有任何单个查询来增加每次更新中的post_count

最佳答案

尝试这样的事情:

POST /test_work/user/d989dd8629f8b6cc59faf8a1aa2328c8/_update
{
   "script" : "ctx._source.post_count+=1"
}

10-07 15:28