elasticsearch 使用新的键值对更新弹性搜索数据
这是弹性搜索中搜索的json响应示例。 我们需要在所有json对象中再添加一个键值对(“spec”:“4gb”),例如elasticsearch 使用新的键值对更新弹性搜索数据,elasticsearch,kibana,elasticsearch,Kibana,这是弹性搜索中搜索的json响应示例。 我们需要在所有json对象中再添加一个键值对(“spec”:“4gb”),例如 { "took": 0, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 25, "max_score": 1, "hits": [ { "_index"
{
"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"
}
}
]
}
}
此更新应在单个命令中完成。请指导我们执行此操作 看一看。您可以准备并使用添加所需的属性
例如:
"_source": {
"id": "01",
"type": "product" ,
"spec": "4gb"
},
"_source": {
"id": "02",
"type": "product" ,
"spec": "4gb"
}
试一试
POST twitter/_update_by_query
{
"script": {
"source": "ctx._source.likes++",
"lang": "painless"
},
"query": {
"term": {
"user": "kimchy"
}
}
}
POST /surtest1/_update_by_query?refresh
{
"script": {
"source": "ctx._source['spec']='4gb'"
}
}