MongoDB弹性搜索映射到地理点 [英] MongoDB Elasticsearch mapping to geopoint

查看:142
本文介绍了MongoDB弹性搜索映射到地理点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Kibana看到我的位置信息作为geo_point。我一直在运行映射和如何做,但我似乎无法弄清楚。 mongodb中的数据如下所示:

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

我将map中存储的值映射为geo_point?

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

推荐答案

在mongoDB中,第一个值是经度,接下来是纬度。您可以在弹性搜索映射中添加地理点数据类型。

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

当您添加数据时,

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

请参阅这个

这篇关于MongoDB弹性搜索映射到地理点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆