# What is the correct way to specify mappings for "geo point" data type to index geo information documents in an elasticsearch index?

**URL:** <https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200>\
**Category:** Elasticsearch\
**Created:** [March 24, 2021, 11:32am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200 "2021-03-24T11:32:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Husnain](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@Husnain](https://discuss.elastic.co/u/Husnain)\
**Post date:** [March 24, 2021, 11:32am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/1 "2021-03-24T11:32:32Z")

</div>

I have configured a logstash pipeline in which I have used filter "logstash-filter-geoip" for getting geo information about the IP Address.I have specified mapping before indexing documents into elasticsearch but it is showing this below error in logstash while indexing documents into elasticsearch.

`[WARN] 2021-03-24 16:35:41.900 [[main]>worker0] elasticsearch - Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"test1", :routing=>nil, :_type=>"_doc"}, #<LogStash::Event:0xc7c54f6>], :response=>{"index"=>{"_index"=>"test1", "_type"=>"_doc", "_id"=>"bwTpY3gB09SioyeoXtLa", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [myloc] of type [geo_point]", "caused_by"=>{"type"=>"parse_exception", "reason"=>"field must be either [lat], [lon] or [geohash]"}}}}}`

This is the mapping which I have done before indexing documents into elasticsearch.

```
PUT /test1
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}

```

This is the document which contains geographical information.

```
{
         "myloc" => {
              "latitude" => 47.6348,
           "region_code" => "WA",
              "timezone" => "America/Los_Angeles",
                    "ip" => "3.7.23.139",
         "country_code2" => "US",
         "country_code3" => "US",
             "longitude" => -122.3451,
              "dma_code" => 819,
           "region_name" => "Washington",
          "country_name" => "United States",
              "location" => {
            "lon" => -122.3451,
            "lat" => 47.6348
        },
             "city_name" => "Seattle",
        "continent_code" => "NA",
           "postal_code" => "98109"
    },
      "@version" => "1",
    "@timestamp" => 2021-03-24T11:05:40.821Z,
          "host" => "0.0.0.0",
       "message" => "3.7.23.139"
}

```

This is my logstash configuration pipeline:-

```
input {
        stdin {}
}

filter {
        geoip {
                source => "message"
                target => "myloc"
        }
}

output {
        stdout {}
        elasticsearch {
                hosts => ["http://localhost:9200"]
                user => "${USERNAME}"
                password => "${PASSWD}"
                index => "test1"
        }
}

```

Please provide some solution.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 24, 2021, 3:33pm UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/2 "2021-03-24T15:33:03Z")

</div>

Could you run

```
GET /test1/_mapping

```

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

---

<div class="post-metadata">

**Author:** ![Husnain](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@Husnain](https://discuss.elastic.co/u/Husnain)\
**Post date:** [March 25, 2021, 6:57am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/3 "2021-03-25T06:57:28Z")

</div>

This is my mapping:-

`GET /test1/_mapping`

```
{
  "test1" : {
    "mappings" : {
      "properties" : {
        "myloc" : {
          "type" : "geo_point"
        }
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 25, 2021, 7:51am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/4 "2021-03-25T07:51:36Z")

</div>

How do you explain that:

```auto
PUT /test1
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}

```

becomes

```auto
{
  "test1" : {
    "mappings" : {
      "properties" : {
        "myloc" : {
          "type" : "geo_point"
        }
      }
    }
  }
}

```

So probably you diid not share initially the exact information. That makes harder to help you.

Anyway, here the problem is that the `geo_point` needs to be set on field `myloc.location` and not `myloc`.

---

<div class="post-metadata">

**Author:** ![Husnain](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@Husnain](https://discuss.elastic.co/u/Husnain)\
**Post date:** [March 25, 2021, 7:55am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/5 "2021-03-25T07:55:50Z")

</div>

I have tried this and I have also added geotemplate for my index.Now that error is solved.  
Can you tell me how can I plot this geoinformation on kibana maps? I am using kibana version 7.11.1

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 25, 2021, 8:01am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/6 "2021-03-25T08:01:10Z")

</div>

That's another question. Please open a question in #elastic-stack:kibana then.

---

<div class="post-metadata">

**Author:** ![Husnain](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@Husnain](https://discuss.elastic.co/u/Husnain)\
**Post date:** [March 25, 2021, 8:08am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/7 "2021-03-25T08:08:52Z")

</div>

Ok.Thanks for your help

---

<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:** [April 22, 2021, 8:09am UTC](https://discuss.elastic.co/t/what-is-the-correct-way-to-specify-mappings-for-geo-point-data-type-to-index-geo-information-documents-in-an-elasticsearch-index/268200/8 "2021-04-22T08:09:02Z")

</div>

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