更新弹性搜索字段的问题

问题描述 投票:0回答:1

这是我的结果源的样子。

{“_ source”:{“姓名”:“我的皇冠愤怒的小鸟3”,“movie_id”:69}}

我需要将名称字段更新为“'哪里是我的王冠'”。我使用了以下查询:

{“script”:{“inline”:“ctx._source.Name ='Where's My Crown'”,“lang”:“painless”},“query”:{“match”:{“movie_id”:69}} }

但我得到了这个错误:

{'type':'illegal_argument_exception','reason':“意外令牌['s']期待[{,';'}]之一。”}

请帮我解决这个问题。

python amazon-web-services elasticsearch updating
1个回答
1
投票

这是因为“Where's My Crown”中有一个单引号会干扰整个字符串周围的单引号。

考虑这样做(使用params):

{  
   "script": {
       "inline": "ctx._source.Name = params.newName",
       "params": {
         "newName": "Where's My Crown"
       },
       "lang": "painless"
   },
   "query": {"match": {"movie_id": 69}}
}
© www.soinside.com 2019 - 2024. All rights reserved.