【发布时间】:2018-08-29 06:23:43
【问题描述】:
我有以下类型的文件。
{
"_index": "example1",
"_type": "doc",
"_id": "8036",
"_score": 1,
"_source": {
"user": "kimchy8036",
"postDate": "2009-11-15T13:12:00",
"locations": [
[
72.79887719999999,
21.193036000000003
],
[
-1.8262150000000001,
51.178881999999994
]
]
}
}
下面是映射:
{
"example1": {
"mappings": {
"doc": {
"properties": {
"locations": {
"type": "geo_point"
},
"postDate": {
"type": "date"
},
"status": {
"type": "long"
},
"user": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
我可以使用以下查询添加多个位置。
POST /example1/_update_by_query
{
"query": {
"match": {
"_id": "3"
}
},
"script" : {
"lang":"painless",
"inline": "ctx._source.locations.add(params.newsupp)",
"params":{
"newsupp":[-74.00,41.12121 ]
}}
}
但无法从位置移除数组对象。我试过下面的查询但工作。 发布示例1/doc/3/_update {
"script" :
{
"lang":"painless",
"inline":"ctx._source.locations.remove(params.tag)",
"params":{
"tag":[-74.00,41.12121]
}
}
}
请让我知道我在哪里做错了。我正在使用弹性版本 5.5.2
【问题讨论】:
-
尝试使用 _update_by_query 而不是 _update 端点
-
我也试过_update_by_query。但它也不起作用。 POST /example1/_update_by_query {“查询”:{“匹配”:{“_id”:“3”}},“脚本”:{“语言”:“无痛”,“内联”:“ctx._source.locations。删除(params.newsupp)", "params":{ "newsupp":[-74.00,41.12121 ] }} }
标签: arrays elasticsearch geolocation match