# Elasticsearch mapping a value

**URL:** <https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593>\
**Category:** Elasticsearch\
**Created:** [July 3, 2016, 5:42am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593 "2016-07-03T05:42:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clemens\_Overbosch](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@Clemens\_Overbosch](https://discuss.elastic.co/u/Clemens_Overbosch)\
**Post date:** [July 3, 2016, 5:42am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593/1 "2016-07-03T05:42:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 3, 2016, 5:47am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593/2 "2016-07-03T05:47:16Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/2.3/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/geo-point.html) is what you want.

---

<div class="post-metadata">

**Author:** ![Clemens\_Overbosch](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@Clemens\_Overbosch](https://discuss.elastic.co/u/Clemens_Overbosch)\
**Post date:** [July 3, 2016, 5:59am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593/3 "2016-07-03T05:59:40Z")

</div>

Hello Mark,

Thanks a bunch for your reply. I have tried getting the hang of that link before.. but I can't seem to figure out what I'm doing wrong.

Since my location is stored as a list/array, I'd assume I need this one, right?

```
PUT my_index/my_type/4
{
  "text": "Geo-point as an array",
  "location": [-71.34, 41.12] 
}

```

So if you like to my mongodb record, I'd say mine would have to look like this:

```
PUT yapdns(index name)/loc(key where lon,lat are stored)/4(what does this 4 mean?)
{
  "loc": "Geo-point as an array",
  "location": [-71.34, 41.12] 
}

```

why does "location": [-71.34, 41.12] already has a value entered?

I also tried this:

```
curl -XPUT 'http://localhost:9200/yapdns/_mapping' -d '
    {
      "mappings": {
        "loc": {
          "properties": {
            "location": {
              "type": "geo_point"
            }
          }
        }
      }
    }
    }
'

```

but got this error:

`{"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: mapping type is missing;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: mapping type is missing;"},"status":400}`

Next I tried:

```
curl -XPUT 'http://localhost:9200/yapdns/_mapping/loc' -d '
{
  "properties": {
    "loc": {
      "type": "geo_point"
    }
  }
}

```

getting the following error on that:

`{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"mapper [loc] cannot be changed from type [string] to [geo_point]"}],"type":"illegal_argument_exception","reason":"mapper [loc] cannot be changed from type [string] to [geo_point]"},"status":400}`

---

<div class="post-metadata">

**Author:** ![Clemens\_Overbosch](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@Clemens\_Overbosch](https://discuss.elastic.co/u/Clemens_Overbosch)\
**Post date:** [July 3, 2016, 7:37am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593/4 "2016-07-03T07:37:34Z")

</div>

Any idea what I'm doing wrong here?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 5, 2016, 6:41pm UTC](https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593/5 "2016-07-05T18:41:18Z")

</div>

> mapper [loc] cannot be changed from type [string] to [geo\_point]

As it says, you can't change the mapping of a field. You have to reindex. If you haven't accrued any data in the index yet just delete it and recreate it.

---

<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 5, 2017, 10:37pm UTC](https://discuss.elastic.co/t/elasticsearch-mapping-a-value/54593/6 "2017-07-05T22:37:52Z")

</div>


