我的ES 7.x系统实时存储geo_point
数据。
喜欢 :
{
"id" : "john",
"age" : 26,
"geo" : "57.233, 129.11"
"address" : "Rovert Hall"
}
我想自动实时获取存储的
geo_shape
数据,从而自动存储geo_point
数据。然后,使用
id
查询并获取make的geo_shape
数据。我怎样才能做到呢?如果这是不可能的,我想得到任何类似的建议。
最佳答案
实现此目的的一种方法是利用script
摄取处理器并动态创建geo_shape
(Point
类型)。
首先创建管道:
PUT _ingest/pipeline/point-to-shape
{
"processors": [
{
"script": {
"source": """
def latLon = /,/.split(ctx.geo);
ctx.shape = [
"type" : "point",
"coordinates" : [latLon[1], latLon[0]]
];
"""
}
}
]
}
然后,我们为您的文档建立索引,只需引用该管道即可,如下所示:
PUT index/_doc/1?pipeline?point-to-shape
{
"id" : "john",
"age" : 26,
"geo" : "57.233, 129.11",
"address" : "Rovert Hall"
}
然后生成的文档将是:
{
"geo" : "57.233, 129.11",
"address" : "Rovert Hall",
"shape" : {
"coordinates" : [
" 129.11",
"57.233"
],
"type" : "point"
},
"id" : "john",
"age" : 26
}
PS:您还需要确保索引的
shape
字段具有正确的geo_shape
映射类型。
关于elasticsearch - 我可以在Elasticsearch 7.x中从get geo_point存储geo_shape吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58872224/