我正在尝试将一个项目添加到我的一个 Elastic Search 文档中的数组中。我可以为简单的项目(例如字符串)执行此操作,但现在无法添加对象。这是我当前的代码:
POST /user_profiles/user_profile/12345/_update
{
"script" : {
"inline": "ctx._source.searches.add(params.search)",
"lang": "painless",
"params" : {
"search" : {
"test": "test2"
}
}
}
}
我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse [searches]"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse [searches]",
"caused_by": {
"type": "illegal_state_exception",
"reason": "Can't get text on a START_OBJECT at 1:29"
}
},
"status": 400
}