ElasticSearch如何设置geo_point
我正在尝试在ES 1.0.0上设置geo_point对象,并对它运行简单的概念证明查询,但是查询无法返回任何匹配。这是我的设置步骤:
1)创建映射:
PUT jay/geotest/_mapping{
    "geotest" : {
        "properties" : {
            "name" : {
                "type" : "string"
            },
            "pin" : {
                "type": "geo_point"   
            }
        }
    }
}
2)验证映射:
GET jay/geotest/_mapping3)添加一条数据
put jay/geotest/1{
   "name": "test1",
   "pin": {
      "lat": 0,
      "lon": 0
   }
}
4)查询该数据:
GET jay/geotest/_search?search_type=count{
    "filtered" : {
        "filter" : {
            "geo_distance" : {
                "distance" : "100km",
                "pin" : {
                    "lat" : 0,
                    "lon" : 0
                }
            }
        }
    }
}
我的预期结果是,我将返回一击,但查询未返回任何内容。
提前致谢!
回答:
我认为您缺少请求的“查询”部分。
POST jay/geotest/_search{
   "query": {
      "filtered": {
         "filter": {
            "geo_distance": {
               "distance": "100km",
               "pin": {
                  "lat": 0,
                  "lon": 0
               }
            }
         }
      }
   }
}
我刚刚测试了您的步骤,然后进行更改返回了文档。
以上是 ElasticSearch如何设置geo_point 的全部内容, 来源链接: utcz.com/qa/432697.html

