# How to specify a geo\_point mapping

**URL:** <https://discuss.elastic.co/t/how-to-specify-a-geo-point-mapping/3784>\
**Category:** Elasticsearch\
**Created:** [January 16, 2011, 9:06pm UTC](https://discuss.elastic.co/t/how-to-specify-a-geo-point-mapping/3784 "2011-01-16T21:06:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kash\_badami](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@kash\_badami](https://discuss.elastic.co/u/kash_badami)\
**Post date:** [January 16, 2011, 9:06pm UTC](https://discuss.elastic.co/t/how-to-specify-a-geo-point-mapping/3784/1 "2011-01-16T21:06:51Z")

</div>

OK, so I have tried unsuccessfully for 2 days now to create a custom mapping for a geo\_point field. According to the docs, I can put a file under config/mapping/\_default to specify a custom mapping for a geo\_point field. So I did like this:

config/mappings/\_default/golfcourse.json

```
  "golfcourse":{
     "properties":{
        "par":{
           "type":"long"
        },
        "phone":{
           "type":"string"
        },
        "numholes":{
           "type":"long"
        },
        "lon":{
           "type":"double"
        },
        "location":{
           "properties":{
            "type" : "geo_point"
           }
        },
        "address":{
           "type":"string"
        },
        "name":{
           "type":"string"
        },
        "state":{
           "type":"string"
        },
        "lat":{
           "type":"double"
        },
        "coursetype":{
           "type":"string"
        },
        "city":{
           "type":"string"
        }
     }
  }

```

}

Then I index golfcourses based on this schema. When I access the mapping like this [http://localhost:8080/index/golfcourse/\_mapping](http://localhost:8080/index/golfcourse/_mapping) I get this:

{

```
index: { }

```

}

No mapping!

When I query, the index/golfcourse type I get results for a normal query like this:

[http://localhost:9200/index/golfcourse/\_search?q=reston](http://localhost:9200/index/golfcourse/_search?q=reston)

When I run a geo query like this:

curl -XGET [http://localhost:9200/index/golfcourse/\_search](http://localhost:9200/index/golfcourse/_search) -d '  
{  
query : {  
filtered : {  
query : {  
match\_all : { }  
}  
,  
filter : {  
geo\_distance : {  
distance : "30mi",  
lat : 45.2879387963343,  
lon : -122.697361707687  
}  
}  
}  
}  
}'

QueryParsingException[[index] field [lon] is not a geo\_point field]

the problem is I have no idea on what the right way to do the mapping is. Unless its dynamic I can't get the mapping override to work, because the docs only give me json snippets. Not a complete mapping file with a full example of a custom mapping.

Please Help!

Regards,  
kash.

---

<div class="post-metadata">

**Author:** ![kash\_badami](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@kash\_badami](https://discuss.elastic.co/u/kash_badami)\
**Post date:** [January 16, 2011, 11:11pm UTC](https://discuss.elastic.co/t/how-to-specify-a-geo-point-mapping/3784/2 "2011-01-16T23:11:51Z")

</div>

Also if I try to create a mapping using the api like this:

curl -XPUT '[http://localhost:9200/index/golfcourse/\_mapping](http://localhost:9200/index/golfcourse/_mapping)' -d '  
{  
"pin" : {  
"properties" : {  
"location" : {  
"properties" : {  
"type" : "geo\_point"  
}  
}  
}  
}  
}  
'

I get the following exception:

{"error":"ElasticSearchException[java.lang.String cannot be cast to java.util.Map]; nested: ClassCastException[java.lang.String cannot be cast to java.util.Map]; "}dhcp-25-229:elasticsearch

Any help would be greatly appreciated. There is something fundamental I am missing here, if I cant solve this issue, I will have to abandon elastic search for this endeavor and I really believe its the right tool.

Regards,  
kash.

---

<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 6, 2017, 4:13am UTC](https://discuss.elastic.co/t/how-to-specify-a-geo-point-mapping/3784/3 "2017-07-06T04:13:47Z")

</div>


