I'm develop a microservice for manage locations with Java/Spring Boot using spring-data-elasticsearch and when try to enter new data to ES using my controller the data input is not mapped properly to a document into ES, specifically the Geopoint attribute "location".
I'm tried using GeoPoint from import org.springframework.data.elasticsearch.core.geo.GeoPoint and from org.springframework.data.elasticsearch.core.geo.GeoPoint, in both cases data saved to ES is not typed as geo_point
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.GeoPointField;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import io.swagger.annotations.ApiModelProperty;
@Document(indexName = "location", type="location")
public class Location {
@Id
@ApiModelProperty(hidden = true)
private String id;
private String appId;
private String resourceId;
@GeoPointField
private GeoPoint location;
private String street;
private String city;
// more attr and method was ommited
}
After save data into ES using ElasticSearchRepository when I get mapping data is showed like:
{
"location" : {
"mappings" : {
"location" : {
"properties" : {
"appId" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"city" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"country" : {
"properties" : {
"countryCcFips" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"countryCcIso" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"countryName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"location" : {
"properties" : {
"lat" : {
"type" : "float"
},
"lon" : {
"type" : "float"
}
}
},
"parish" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
// ommited more json data
Please, I need that GeoPoint field (location) will mapped to geo_point into ES, is important to execute Geoqueries properly.
I'm , using Spring Data ElasticSearch, with Spring Boot 2.1.3.RELEASE and ElasticSearch driver 6.4.3 with ElasticSearch server 6.4
GeoPointclass or theGeoPointFieldannotation to have the field typed as "geo_point". This place in the code hasn't changed for years. I will try to reproduce this with a local example, but can't promise that I will find the time today.