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.