# How to set geo\_point type from csv files using logstash?

**URL:** <https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182>\
**Category:** Logstash\
**Created:** [June 8, 2020, 1:35pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182 "2020-06-08T13:35:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jun.8](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jun.8/32/68749_2.png) [@Jun.8](https://discuss.elastic.co/u/Jun.8)\
**Post date:** [June 8, 2020, 1:35pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/1 "2020-06-08T13:35:49Z")

</div>

Hi, I'm trying to set geo\_point type from csv files which have latitude and longitude using logstash. But I really don't know how to convert latitude and longitude to location(geo\_point type). I'm using logstash for this, but it seems that there is not enough information about it.  
I found this way.

```
input {
  file {
    path => "/Users/kakao/Downloads/coronavirusdataset_20200601/Case.csv"
    start_position => "beginning"
    #sincedb_path => "/dev/null"    
  }
}
filter {
  csv {
      separator => ","
      columns => ["case_id","province","city","group","infection_case","confirmed","latitude","longitude"]
  }
  mutate {convert => ["latitude", "float"]}
  mutate {convert => ["longitude", "float"]}
  mutate {convert => ["confirmed", "float"]}
  mutate {rename => ["latitude", "[location][lat]"]}
  mutate {rename => ["longitude", "[location][lon]"]}
output {  
    elasticsearch {
        template => "/Users/kakao/Downloads/logstash-7.7.1/config/elasticsearch-template.json"
        template_overwrite => true
        action => "index"
        hosts => ["http://localhost:9200"]
        index => "logstash-%{+YYYY.MM.dd}"
        user => "user-name"
        password => "password"
        workers => 1
    }
    stdout {}
}

```

and this is my elasticsearch-template.json.

```
{
    "template" : "logstash-*",
    "settings" : {
      "index.refresh_interval" : "5s"
    },
    "mappings" : {
      "_default_" : {
        "_all" : {"enabled" : true, "omit_norms" : true},
        "dynamic_templates" : [ {
          "message_field" : {
            "match" : "message",
            "match_mapping_type" : "string",
            "mapping" : {
              "type" : "string", "index" : "analyzed", "omit_norms" : true,
              "fielddata" : { "format" : "disabled" }
            }
          }
        }, {
          "string_fields" : {
            "match" : "*",
            "match_mapping_type" : "string",
            "mapping" : {
              "type" : "string", "index" : "analyzed", "omit_norms" : true,
              "fielddata" : { "format" : "disabled" },
              "fields" : {
                "raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
              }
            }
          }
        } ],
        "properties" : {
          "@timestamp": { "type": "date" },
          "@version": { "type": "string", "index": "not_analyzed" },
          "geoip" : {
            "dynamic": true,
            "properties" : {
              "ip": { "type": "ip" },
              "location" : { "type" : "geo_point" },
              "latitude" : { "type" : "float" },
              "longitude" : { "type" : "float" }
            }
          },
    "location" : { "type": "geo_point" }
        }
      }
    }
  }

```

Finally, I got geoip.location which is geo\_point type, but I couldn't find any data of geoip.location in discover. I only have location.lat, location.lon which are numbers. It means that I just have field, but no data in that field.

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_kumar4/32/67369_2.png) [@Rahul\_Kumar4](https://discuss.elastic.co/u/Rahul_Kumar4)\
**Post date:** [June 8, 2020, 2:56pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/2 "2020-06-08T14:56:27Z")

</div>

You may have to refresh your index pattern from Kibana console for the new fields to appear if the index already existed from before and the mappings was changed.

---

<div class="post-metadata">

**Author:** ![Jun.8](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jun.8/32/68749_2.png) [@Jun.8](https://discuss.elastic.co/u/Jun.8)\
**Post date:** [June 8, 2020, 3:12pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/3 "2020-06-08T15:12:49Z")

</div>

![스크린샷 2020-06-09 오전 12.10.52](https://us1.discourse-cdn.com/elastic/original/3X/5/d/5d23b4a1d602004f57ff67bac930d9ff440c6742.png) ![스크린샷 2020-06-09 오전 12.11.03](https://us1.discourse-cdn.com/elastic/original/3X/c/c/cc62863ad8871add6e42f1f8356c78d4ac462ead.png) ![스크린샷 2020-06-09 오전 12.11.32](https://us1.discourse-cdn.com/elastic/original/3X/0/1/012893cc96835ce95502e1f634bcb983347103e1.png)

The problem is like above. When I look at discover, it only has location.lat and location.lon fields. There is no geoip.location what I want....

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_kumar4/32/67369_2.png) [@Rahul\_Kumar4](https://discuss.elastic.co/u/Rahul_Kumar4)\
**Post date:** [June 8, 2020, 3:15pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/4 "2020-06-08T15:15:15Z")

</div>

> [@Jun.8](#):
>
> The problem is like above. When I look at discover, it only has location.lat and location.lon fields. There is no geoip.location what I want....

Did you try refreshing the index pattern?

---

<div class="post-metadata">

**Author:** ![Jun.8](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jun.8/32/68749_2.png) [@Jun.8](https://discuss.elastic.co/u/Jun.8)\
**Post date:** [June 8, 2020, 3:17pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/5 "2020-06-08T15:17:51Z")

</div>

![스크린샷 2020-06-09 오전 12.17.10](https://us1.discourse-cdn.com/elastic/original/3X/f/5/f522d0db73c95f8e14c2c1a68b35cf3cf4d7ec81.png)  
Yes, I just have refreshed the index pattern, but it outputs same result.  
Should I have datas related to "geoip" in the csv file I'm using? Cause I only have longitude and latitude datas...

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [June 8, 2020, 6:27pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/6 "2020-06-08T18:27:55Z")

</div>

> [@Jun.8](#):
>
> ```auto
> mutate {rename => ["latitude", "[location][lat]"]}
> mutate {rename => ["longitude", "[location][lon]"]}
> 
> ```

change this to

```
mutate {rename => ["latitude", "[geoip][location][lat]"]}
  mutate {rename => ["longitude", "[geoip][location][lon]"]}

```

---

<div class="post-metadata">

**Author:** ![Jun.8](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jun.8/32/68749_2.png) [@Jun.8](https://discuss.elastic.co/u/Jun.8)\
**Post date:** [June 12, 2020, 3:14pm UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/7 "2020-06-12T15:14:56Z")

</div>

Thanks for your reply.. But it doesn't work anyway..  
If like that, there is no geoip.location which is geo\_point type.

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [June 13, 2020, 1:59am UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/8 "2020-06-13T01:59:55Z")

</div>

geo\_point data type accepts latitude longitude pair. in your previous screenshot you already have geoip.location with geo\_point data type. which means you only need to add lat-lon pair to that field, which is why i suggested the previous step.  
latitude and longitude are stored as numeric float.

more info about [geo\_point](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 11, 2020, 2:00am UTC](https://discuss.elastic.co/t/how-to-set-geo-point-type-from-csv-files-using-logstash/236182/9 "2020-07-11T02:00:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
