【问题标题】:ElasticSearch how to setup geo_pointElasticSearch 如何设置 geo_point
【发布时间】:2014-02-22 01:17:38
【问题描述】:

我正在尝试在 ES 1.0.0 上设置 geo_point 对象并针对它运行一个简单的概念验证查询,但查询未能返回任何命中。以下是我的设置步骤:

1) 创建映射:

PUT jay/geotest/_mapping
{
    "geotest" : {
        "properties" : {
            "name" : {
                "type" : "string"
            },
            "pin" : {
                "type": "geo_point"   
            }
        }
    }
}

2) 验证映射:

GET jay/geotest/_mapping

3) 添加一条数据

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
                }
            }
        }
    }
}

我的预期结果是我将返回一个命中,但查询没有返回任何内容。

提前致谢!

【问题讨论】:

标签: elasticsearch


【解决方案1】:

我认为您缺少请求的“查询”部分。

POST jay/geotest/_search
{
   "query": {
      "filtered": {
         "filter": {
            "geo_distance": {
               "distance": "100km",
               "pin": {
                  "lat": 0,
                  "lon": 0
               }
            }
         }
      }
   }
}

我刚刚测试了您的步骤,进行更改会返回文档。

【讨论】:

  • 就是这样!谢谢阿克谢!
猜你喜欢
  • 2013-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-31
  • 2015-06-14
相关资源
最近更新 更多