elasticsearch update api - 脚本不更改索引文档
elasticsearch update api - script do not change indexed document
我正在尝试在 elasticsearch 1.3.5 中使用更新 api。我正在尝试更新以下文档:
{
"_index": "geocode",
"_type": "google",
"_id": "kolb dfsafa 303 46546456 z ",
"_version": 8,
"_score": 1,
"_source": {
"results": [
{"formatted_address": "kolb 303, 46546456 dfsafa-dfsafa-d",
"geometry": {
"location": {
"lat": 35.0360533,
"lng": 14.5632209
},
"location_type": "ROOFTOP"
},
"types": [
"street_address"
]
}
],
"status": "OK"
}
}
我有以下脚本:
POST /geocode/google/kolb%20dfsafa%20303%2046546456%20z%20/_update
{
"script":"ctx._source.results.geometry.location.lat==latitude",
"lang": "groovy",
"params":{
"latitude" : 0.0
}
}
我想将纬度位置更新为 0.0。 Api 调用成功完成(版本增加等)但是没有任何更新。
{
"_index": "geocode",
"_type": "google",
"_id": "kolb dfsafa 303 46546456 z ",
"_version": 9
}
有什么提示吗?
由于 results 是 array ,您需要将其作为数组来寻址。请记住,您正在处理原始 _source 而不是来自字段数据缓存的数据。这意味着您需要使用正确的 JSON 路径。
POST /geocode/google/kolb%20dfsafa%20303%2046546456%20z%20/_update
{
"script":"ctx._source.results[0].geometry.location.lat=latitude",
"lang": "groovy",
"params":{
"latitude" : 0.0
}
}
您可以参考此 link 以了解有关此用例的更多信息以及有关更新 API
的更多示例
我正在尝试在 elasticsearch 1.3.5 中使用更新 api。我正在尝试更新以下文档:
{
"_index": "geocode",
"_type": "google",
"_id": "kolb dfsafa 303 46546456 z ",
"_version": 8,
"_score": 1,
"_source": {
"results": [
{"formatted_address": "kolb 303, 46546456 dfsafa-dfsafa-d",
"geometry": {
"location": {
"lat": 35.0360533,
"lng": 14.5632209
},
"location_type": "ROOFTOP"
},
"types": [
"street_address"
]
}
],
"status": "OK"
}
}
我有以下脚本:
POST /geocode/google/kolb%20dfsafa%20303%2046546456%20z%20/_update
{
"script":"ctx._source.results.geometry.location.lat==latitude",
"lang": "groovy",
"params":{
"latitude" : 0.0
}
}
我想将纬度位置更新为 0.0。 Api 调用成功完成(版本增加等)但是没有任何更新。
{
"_index": "geocode",
"_type": "google",
"_id": "kolb dfsafa 303 46546456 z ",
"_version": 9
}
有什么提示吗?
由于 results 是 array ,您需要将其作为数组来寻址。请记住,您正在处理原始 _source 而不是来自字段数据缓存的数据。这意味着您需要使用正确的 JSON 路径。
POST /geocode/google/kolb%20dfsafa%20303%2046546456%20z%20/_update
{
"script":"ctx._source.results[0].geometry.location.lat=latitude",
"lang": "groovy",
"params":{
"latitude" : 0.0
}
}
您可以参考此 link 以了解有关此用例的更多信息以及有关更新 API
的更多示例