# Automatic setting of geo\_point mapping type

**URL:** <https://discuss.elastic.co/t/automatic-setting-of-geo-point-mapping-type/10823>\
**Category:** Elasticsearch\
**Created:** [February 20, 2013, 3:55pm UTC](https://discuss.elastic.co/t/automatic-setting-of-geo-point-mapping-type/10823 "2013-02-20T15:55:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mihai\_Cazacu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mihai_cazacu/32/2366_2.png) [@Mihai\_Cazacu](https://discuss.elastic.co/u/Mihai_Cazacu)\
**Post date:** [February 20, 2013, 3:55pm UTC](https://discuss.elastic.co/t/automatic-setting-of-geo-point-mapping-type/10823/1 "2013-02-20T15:55:16Z")

</div>

Hi,

Having this classes:

class Location {

> ```
> double lon
> double lat
> 
> ```
> 
> }  
> class Address {  
> String name  
> Location location  
> }

is there a way (via Annotations, etc) to specify that the location field  
must be mapped with "geo\_point" type (without generating explicitly the  
mapping for the Address)?

Right now I'm doing this way:

client.admin()

> ```
> .indices()
> .preparePutMapping(DB_NAME)
> .setType(ADDRESS_TYPE_NAME)
> .setSource(XContentFactory.jsonBuilder()...)
> .execute().actionGet()
> 
> ```

but it would be nice to skip the source generation.

If I skip the previous step (registering mapping), elasticsearch will  
generate this mapping for "location" field as:

location: {

> dynamic: "true",  
> properties: {  
> lat: {  
> type: "double"  
> },  
> lon: {  
> type: "double"  
> }  
> }  
> }

Thanks,  
Mihai

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Mihai\_Cazacu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mihai_cazacu/32/2366_2.png) [@Mihai\_Cazacu](https://discuss.elastic.co/u/Mihai_Cazacu)\
**Post date:** [February 20, 2013, 8:22pm UTC](https://discuss.elastic.co/t/automatic-setting-of-geo-point-mapping-type/10823/2 "2013-02-20T20:22:27Z")

</div>

Resolved. It seems that I need to register a custom template.

Regards,  
Mihai

On Wednesday, February 20, 2013 5:55:16 PM UTC+2, Mihai Cazacu wrote:

> Hi,
> 
> Having this classes:
> 
> class Location {
> 
> > ```
> > double lon
> > double lat
> > 
> > ```
> > 
> > }  
> > class Address {  
> > String name  
> > Location location  
> > }
> 
> is there a way (via Annotations, etc) to specify that the location field  
> must be mapped with "geo\_point" type (without generating explicitly the  
> mapping for the Address)?
> 
> Right now I'm doing this way:
> 
> client.admin()
> 
> > ```
> > .indices()
> > .preparePutMapping(DB_NAME)
> > .setType(ADDRESS_TYPE_NAME)
> > .setSource(XContentFactory.jsonBuilder()...)
> > .execute().actionGet()
> > 
> > ```
> 
> but it would be nice to skip the source generation.
> 
> If I skip the previous step (registering mapping), elasticsearch will  
> generate this mapping for "location" field as:
> 
> location: {
> 
> > dynamic: "true",  
> > properties: {  
> > lat: {  
> > type: "double"  
> > },  
> > lon: {  
> > type: "double"  
> > }  
> > }  
> > }
> 
> Thanks,  
> Mihai

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:50am UTC](https://discuss.elastic.co/t/automatic-setting-of-geo-point-mapping-type/10823/3 "2017-07-06T02:50:27Z")

</div>


