gpt4 book ai didi

java - geo_point 类型的不同格式?

转载 作者:行者123 更新时间:2023-12-02 07:47:59 24 4
gpt4 key购买 nike

来自此处的文档:http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

它说 geo_point 接受不同的格式。例如:支持这两个

  1. "location" : "-71.34, 41.12"

  2. "location" : { "lat" : 41.12, "lon" : -71.34 }

我想问一下这两个是一样的吗?我正在使用 ES 0.17.6 并遇到此问题:

当我使用 (1) 格式建立索引时,无法使用 (2) 格式进行搜索。如果我用(1)格式再次搜索,成功了。

例如:如果我用(2)格式索引:

curl -XPUT 'http://localhost:9200/twitter/pin/1' -d '
{
"pin" : {
"location" : {
lat: 41.12,
lon: -71.34
},
"tag" : ["food", "family"],
"text" : "my favorite family restaurant"
}
}'

我无法使用此 (1) 格式进行搜索

curl -XGET 'http://localhost:9200/twitter/pin/_search' -d '
{
"query": {
"filtered" : {
"query" : {
"field" : { "text" : "restaurant" }
},
"filter" : {
"geo_distance" : {
"distance" : "12km",
"pin.location" : "-71.34, 41.12"
}
}
}
}
}
'

如果我使用(2)格式搜索将会成功:

2. "pin.location" : {
"lat" : 41.12,
"lon" : -71.34
}

最佳答案

当 geo_point 表示为字符串时,它应遵循 lat lon 格式:"pin.location": "41.12, -71.34"

关于java - geo_point 类型的不同格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10577251/

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