更新弹性搜索嵌套索引值

问题描述 投票:0回答:1

我在弹性搜索中有一个具有嵌套值的索引,我想用ID更新嵌套索引中的值,我该如何实现。我的索引就像

{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": 1.0,
        "hits": [
            {
                "_index": "a",
                "_type": "a1",
                "_id": "my-index1",
                "_score": 1.0,
                "_source": {
                    "id": "my-index1",
                    "name": "firstIndex",
                    "metals": [
                        {
                            "id": "123",
                            "name": "Ronni",   
                        },
                         {
                            "id": "124",
                            "name": "Ross",   
                        }
                    ]
                }
            }
        ]
    }
}

我想借助“ Id” -124用“ Monika”更新“ Ross”,请提出建议

elasticsearch elasticsearch-5
1个回答
0
投票

假设您的metals属于nested datatype(而不仅仅是一个简单的嵌套数组),您可以首先使用nested词条查询限制要更新的文档,然后使用循环的nested来限制执行更改:

script
© www.soinside.com 2019 - 2024. All rights reserved.