MongoDB Elasticsearch mapping to geopoint

不羁岁月 提交于 2020-01-25 20:13:48

问题


I'm trying to get Kibana to see my location info as a geo_point. I've been running about mapping and how to do it, but I can't seem to figure it out. The data looks like this in mongodb:

{ "_id" : "3", "loc" : "[-122.0574, 37.41919999999999]", "fs" : "Clean", "name" : "www.googleapis.com", "timestamp" : "2016-07-02T21:02:53.623Z", "destination" : "192.168.79.136", "source" : "216.58.212.138", "vt" : "0" }

How would I map the values that are stored in the key "loc" as geo_point?


回答1:


In mongoDB the first value is longitude and the next is latitude.You can add a geo point data type to your elasticsearch mapping.

PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "loc": {
          "type": "geo_point"
        }
      }
    }
  }
}

And when you add data,

PUT my_index/my_type/3
{
  "loc": { 
    "lat": 37.41919999999999,
    "lon": -122.0574
  }
}

Refer to this



来源:https://stackoverflow.com/questions/38166978/mongodb-elasticsearch-mapping-to-geopoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!