gpt4 book ai didi

elasticsearch - Elasticsearch和geo_shape

转载 作者:行者123 更新时间:2023-12-03 02:02:57 26 4
gpt4 key购买 nike

我正在尝试使用 elasticsearch 1.1.2 向现有应用程序中添加一些地理特征。此应用程序具有person,属性pin表示地理定位点。

这是映射:

{"person":{"properties":{"pin":{"type":"geo_point"}}}}

这是一个更新人的例子:
{"doc":{
"full_name":"Oleta Yost",
"pin":{"lat":47.123, "lon":-1.15}
}}

和我的查询:
{ "from":0,
"size":24,
"query":{
"filtered":{
"filter":{
"and":[
{"or":[
{"term": /* some term filter */ },
{"term": /* some term filter */ }
]},
{ "geo_shape":{
"person.pin":{
"shape":{
"type":"envelope",
"coordinates":[[46,47],[-10,10]]
}
}
}
}
]
},
"query":{
"query_string":{
"fields":["person.full_name^10"],
"query":"full_name:\"Oleta Yost\""
}
}
}
}
}

此查询引发异常:
Field [person.pin] is not a geo_shape

我尝试了很多解决方案
  • 使用字符串或数组来定义我的pin更新,例如)
  • https://github.com/elastic/elasticsearch/issues/10500

  • 我不知道我的问题在哪里...你能指出我吗?

    最佳答案

    上面的查询使用的geoshape query仅适用于类型为geoshape的字段。
    在上面的映射中,该字段是geopoint

    一种方法是将类型更改为geoshape:

    "person": {
    "properties": {
    "pin": {
    "type": "geo_shape"
    }
    }
    }

    引脚的json数据将是:
    pin : {
    "type" : "Point",
    "coordinates" : [ 46,47]
    }

    关于elasticsearch - Elasticsearch和geo_shape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30104676/

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