【问题标题】:Elasticsearch geo_point query_parsing_exceptionElasticsearch geo_point query_parsing_exception
【发布时间】:2016-10-16 21:32:51
【问题描述】:

我尝试通过索引单个文档来遵循文档中的示例:

curl -XPUT 'localhost:9200/graph/nodes/1' -d'
{        
    "pin" : {
        "location" : {
            "lat" : 40.12,
            "lon" : -71.34
        }
    }
}
'

这给出了映射:

{
  "graph" : {
    "mappings" : {
      "nodes" : {
        "properties" : {
          "location" : {
            "type" : "double"
          },
          "pin" : {
            "properties" : {
              "location" : {
                "properties" : {
                  "lat" : {
                    "type" : "double"
                  },
                  "lon" : {
                    "type" : "double"
                  }
                }
              }
            }
          },
          "text" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

当我尝试按与某个点的距离进行查询时,会出现如下错误:

failed to find geo_point field [pin.location]

我给出的查询如下:

curl -XPOST 'localhost:9200/graph/_search?pretty' -d'
{
  "query" : {
    "bool":{
      "must":{
        "match_all":{}
      },
      "filter":{
        "geo_distance":{
          "distance":"200km",
            "pin.location":{
              "lat":40,
              "lon":-70
            }
          }
        }
      }
    }
  }
}
'

我不确定我在哪里出错了,所以任何建议都会很棒!

提前致谢

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    要使用地理查询,您的位置需要是 geo_point 或 geo_shape 类型。

    将映射更改为

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      • 1970-01-01
      相关资源
      最近更新 更多