elasticsearch 弹性搜索中未生成Geohash,elasticsearch,geolocation,geospatial,geohashing,elasticsearch,Geolocation,Geospatial,Geohashing" /> elasticsearch 弹性搜索中未生成Geohash,elasticsearch,geolocation,geospatial,geohashing,elasticsearch,Geolocation,Geospatial,Geohashing" />

elasticsearch 弹性搜索中未生成Geohash

elasticsearch 弹性搜索中未生成Geohash,elasticsearch,geolocation,geospatial,geohashing,elasticsearch,Geolocation,Geospatial,Geohashing,我创建了一个索引,如下所示: POST /cabtrails { "settings" : { "number_of_shards" : 3, "number_of_replicas" : 1 }, "mappings" : { "cabtrail" :{ "properties" : { "location": { "type": "geo_point", "geohash_prefi

我创建了一个索引,如下所示:

POST /cabtrails
{
  "settings" :
{
  "number_of_shards" : 3,
  "number_of_replicas" : 1
 },
"mappings" : {
"cabtrail" :{
  "properties" : {
        "location": {
            "type":               "geo_point",
            "geohash_prefix":     true, 
            "geohash_precision":  "5m" 
          },
          "capture_time": {
                "type" : "long"

            },
          "client_id": {
            "type" : "long"

          }
       }
     }
   }
}
它工作正常,并创建了一个索引

我已输入一份样本文档,如下所示:

POST cabtrails/cabtrail
{
    "capture_time": 1431849367077,
    "client_id": 865527029812357,
    "location": "13.0009316,77.5947316"
}
这也很好用。 在这里,我希望ElasticSearch将生成一个我可以使用的geohash字段/条目

但是,当我询问时,我得到了:

GET cabtrails/_search
{
   "took": 2,
   "timed_out": false,
   "_shards": {
      "total": 3,
      "successful": 3,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "cabtrails",
            "_type": "cabtrail",
            "_id": "AU2LrEaze2aqxPjHm-UI",
            "_score": 1,
            "_source": {
               "capture_time": 1431849367077,
           "client_id": 865527029812357,
           "location": "13.0009316,77.5947316"
        }
     }
      ]
   }
}
我希望在查询结果的某个地方有一个类似于
u10hbp
的地理哈希字符串,我可以用它来查询未来的位置点。或者我对geohash+ES的概念搞砸了??救命

根据geo_point中的启用geohash标志索引geohash值

索引的内容和响应字段表示的内容有所不同

响应中的_source字段是传递给elasticsearch索引的原始json文档

启用geohash标志时,将使用geohash表示对geo_点类型进行索引,但不会更改实际的源文档

要了解geohash标志如何补充geo_点类型索引的方式,您可能需要使用api:

对于上面的示例,它将在以下几行中显示:

**Query**
POST cabtrails/_search
{

    "fielddata_fields" :["location","location.geohash"]
}
响应:

"hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "cabtrails",
            "_type": "cabtrail",
            "_id": "AU2NRn_OsXnJTKeurUsn",
            "_score": 1,
            "_source": {
               "capture_time": 1431849367077,
               "client_id": 865527029812357,
               "location": "13.0009316,77.5947316"
            },
            "fields": {
               "location": [
                  {
                     "lat": 13.0009316,
                     "lon": 77.5947316
                  }
               ],
               "location.geohash": [
                  "t",
                  "td",
                  "tdr",
                  "tdr1",
                  "tdr1v",
                  "tdr1vw",
                  "tdr1vww",
                  "tdr1vwwz",
                  "tdr1vwwzb",
                  "tdr1vwwzbm"
               ]
            }
         }
      ]
   }