gpt4 book ai didi

elasticsearch - 使用新的键值对更新 Elasticsearch 数据

转载 作者:行者123 更新时间:2023-12-02 22:13:20 25 4
gpt4 key购买 nike

{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 25,
"max_score": 1,
"hits": [
{
"_index": "surtest1",
"_type": "catalog",
"_id": "prod_9876561740",
"_score": 1,
"_source": {
"id": "01",
"type": "product"
}
},
{
"_index": "surtest1",
"_type": "catalog",
"_id": "prod_9876543375",
"_score": 1,
"_source": {
"id": "02",
"type": "product"
}
}
]
}
}

这是 Elasticsearch 中搜索的示例 json 响应。我们需要在所有 json 对象中添加一个键值对(“spec”:“4gb”),例如,

"_source": {
"id": "01",
"type": "product" ,
"spec": "4gb"
},
"_source": {
"id": "02",
"type": "product" ,
"spec": "4gb"
}

此更新应在单个命令中进行。请指导我们执行此操作。

最佳答案

尝试

POST /surtest1/_update_by_query?refresh
{
"script": {
"source": "ctx._source['spec']='4gb'"
}
}

关于elasticsearch - 使用新的键值对更新 Elasticsearch 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49110741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com