【发布时间】:2017-07-02 21:53:53
【问题描述】:
我正在使用 Elasticsearch 5.4,并尝试从嵌套数据类型中删除一个元素。
我有以下映射:
"links_to_asset": {
"type": "nested",
"properties": {
"note_link_id": {
"type": "long"
},
"user_id": {
"type": "long"
},
"creation": {
"type": "date",
"format": "date_hour_minute_second"
},
"modification": {
"type": "date",
"format": "date_hour_minute_second"
},
"to_asset": {
"type": "integer"
},
"from_asset": {
"type": "integer"
},
"comment": {
"type": "text",
"fields": {
"std": {
"type": "text",
"analyzer": "asset_en_analyzer",
"fields": {
"std": {
"type": "text",
"analyzer": "standard"
}
}
}
}
}
}
}
我在 Postman 中尝试过以下操作:
localhost:9200/asset/bookmark/20976/_update?pretty
{
"script": "ctx._source.links_to_asset.removeAll{it['note_link_id'] == id}",
"params": {
"id": 7343
}
}
但我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[NvXYDwh][127.0.0.1:9300][indices:data/write/update[s]]"
}
],
"type": "illegal_argument_exception",
"reason": "failed to execute script",
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... .links_to_asset.removeAll{it['links_to_asset.note_ ...",
" ^---- HERE"
],
"script": "ctx._source.links_to_asset.removeAll{it['links_to_asset.note_link_id'] == id}",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "unexpected token ['{'] was expecting one of [{<EOF>, ';'}]."
}
}
},
"status": 400
}
我已经按照 StackOverflow [1] [2] 上几个不同问题的建议,但没有成功。
嵌套对象是有效的,因为我已经用数据填充了它。另外,id 值也是有效的。
【问题讨论】:
标签: elasticsearch