# Geo\_point field not mapped correctly with aliases

**URL:** <https://discuss.elastic.co/t/geo-point-field-not-mapped-correctly-with-aliases/27620>\
**Category:** Elasticsearch\
**Created:** [August 18, 2015, 9:31pm UTC](https://discuss.elastic.co/t/geo-point-field-not-mapped-correctly-with-aliases/27620 "2015-08-18T21:31:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deejay](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@deejay](https://discuss.elastic.co/u/deejay)\
**Post date:** [August 18, 2015, 9:31pm UTC](https://discuss.elastic.co/t/geo-point-field-not-mapped-correctly-with-aliases/27620/1 "2015-08-18T21:31:37Z")

</div>

Hi. I am failing to get a geo\_point field mapping to work correctly with aliases in java. I have a template that defines my mappings as below:

```
{
    "template_1" : {
        "template" : "examples",
        "aliases" : {
    		"{index}" : {}
  		},
		"mappings": {
			   "example":{
				  "properties":{		
					"location" : {
						"type" : "geo_point"
					}
				  }
			  }
		}
    }
}

```

When I do not use aliases, the location field is mapped correctly as a geo\_point and I can successfully perform queries such as:

```
.addSort(SortBuilders.geoDistanceSort("location").point(latitude, longitude).order(SortOrder.ASC)) 

```

However, when I use aliases I get an exception containing the below:

> ElasticsearchIllegalArgumentException[failed to find mapper for [location] for geo distance based sort]

When I look at the elasticsearch logs I see that the mapping using the alias is:

> successfully updated master with mapping update: index [myalias], indexUUID [crgz4gkNTtapf5IgTXaRDy], type [example] and source [{"example":{"properties":{"location":{"properties":{"lat":{"type":"double"},"lon":{"type":"double"}}}}}}]

Which would explain why I am getting the exception.

I am adding the alias as below:

```
client.admin().indices().prepareAliases().addAlias("examples", "myalias");
...
builder.startObject("location")
.field("lat", latitude)
.field("lon", longitude);
builder.endObject();
...
bulkRequest.add(client.prepareIndex("myalias", "example", id).setSource(builder));

```

Could someone please assist? Thanks.

---

<div class="post-metadata">

**Author:** ![deejay](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@deejay](https://discuss.elastic.co/u/deejay)\
**Post date:** [September 2, 2015, 12:41pm UTC](https://discuss.elastic.co/t/geo-point-field-not-mapped-correctly-with-aliases/27620/2 "2015-09-02T12:41:04Z")

</div>

Does anyone have geo\_point working with aliases using the Java API? Still struggling 😩

---

<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, 11:52pm UTC](https://discuss.elastic.co/t/geo-point-field-not-mapped-correctly-with-aliases/27620/3 "2017-07-05T23:52:37Z")

</div>


