1
私は、ネストされたタイプを持っていると私は更新を実行するために、特定のオブジェクトのインデックスを取得する必要があります:Elasticsearch:無痛スクリプトでオブジェクトのインデックスを取得します
{
"_index": "asset_en_v1",
"_type": "note",
"_id": "23217",
"_version": 24,
"found": true,
"_source": {
"user_id": "11",
"title": "Title",
"note": "Note.",
"creation": "2017-05-31T21:36:01",
"modification": "2017-05-31T21:36:01",
"links": [
{
"note_link_id": "7310",
"user_id": "11",
"creation": "2017-06-01T14:41:50",
"modification": "2019-06-01T14:42:00",
"comment": "Comment goes here."
},
{
"note_link_id": "7311",
"user_id": "11",
"creation": "2017-06-01T14:42:42",
"modification": "2019-06-01T14:42:00",
"comment": "Yep..."
},
{
"note_link_id": "7312",
"user_id": "11",
"creation": "2017-06-01T15:33:55",
"modification": "2017-06-01T15:34:00",
"comment": "Jumo."
}
]
}
}
これまでのところ、私は中_update
文を作成しました無痛スクリプトはがほとんどが仕事をしていませんが、私は試合を得るのに苦労してること:ここで
{
"script": {
"lang": "painless",
"inline": "def note_link_id = 7311; def links = ctx._source.links; for (int i = 0; i < links.length; ++i) { if (links[i].note_link_id == note_link_id) { ctx._source.links[note_link_id].comment = params.comment; ctx._source.links[note_link_id].modification = params.modification } }",
"params": {
"modification": "2019-06-01T14:42:00",
"comment": "QWERTY!"
}
}
}
、links[i].note_link_id == note_link_id
が一致していません。
アイデア?あなたのインラインスクリプトで
スニル++で、私は++されている必要があり、提案していただきありがとうございます。結局、私は別のテクニックを使用しなければなりませんでした。あなたのアイデアがうまくいくかどうかを確認するための変更を加える立場にはありません。しかし、私が将来この問題に戻ると、私はこれを覚えています。 –