2

我正在尝试将一个项目添加到我的一个 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
}
4

1 回答 1

0

我发现了这个问题。它与查询本身无关。问题是索引的映射不包含附加字段。

于 2017-04-05T14:25:32.510 回答