我正在使用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"
}
}
}
}
}
}
}
我在邮递员中尝试了以下内容:
localhost:9200 / asset / bookmark / 20976 / _update?漂亮
{
"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
值也有效 .
1 回答
您尝试编写
groovy
脚本,但您使用的脚本语言是Elasticsearch 5.x中的painless
尝试类似的东西