简体   繁体   中英

mapping geo_point from MongoDB to Elasticsearch

I'm trying to use Kibana to see location info as a geo_point. Data has already transfered from Mongodb to ElasticSearch. The data looks like this in Mongodb:

{ "_id" : "1", "location" : "42.2734, -83.7133", "dst_ip" : "192.168.79.136", "src_ip" : "35.139.46.72" }

I found a question like mine, so I use string type in Mongodb, but in ElasticSearch the value of "location" is also string.

So, how do I map the values that should be stored as a geo_point?

You should create proper mapping in ES first, smth like

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

You need this because ES is not schema-less, and data interpreted, analyzed and processed at index time. After this, you can index data in form you already have - comma separated string with coords is just fine.

See geo point docs for more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM