【问题标题】:Different formats of geo_point type?geo_point 类型的不同格式?
【发布时间】:2012-05-14 03:35:54
【问题描述】:

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

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

  1. “位置”:“-71.34, 41.12”

  2. “位置”:{ “纬度”:41.12, “隆”:-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
    }

【问题讨论】:

    标签: java lucene geolocation elasticsearch


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 2016-09-30
      相关资源
      最近更新 更多