I have an index in Elasticsearch in which there is a field of geo_point. The mapping file is somewhat like this.
curl -XPUT 'localhost:9200/test_geo5' -d'
{
"mappings":{
"test_geo5":{
"properties":{
"lat":{ "type": "string","index": "not_analyzed"},
"lon":{ "type": "string","index": "not_analyzed"},
"message_geocoordinates":{ "type": "geo_point"}
}
}
}
}'
I want to insert message_geocoordinates using java code.
So I wrote java code like this
String latitude= xxxxx;
String longitude= yyyy;
String message_geocordinates= latitude+","+longitude;
JSONObject jj = new JSONObject();
jj.put("lat", latitude);
jj.put("lon", longitude);
IndexResponse response = client.prepareIndex("test_geo5", "iiiii").setSource(jj.toString()).execute().actionGet();
and I tried to insert it in Elasticsearch. But I received following exception.
So it says that my message_geocoordinates field is String in java but it is GeoPointFieldType for elatic search.
How can I insert geopoint field into elasticsearch using java code.