Error on inserting geo_point in elasticsearch through java


(Ankureck) #1

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.


(Mark Harwood) #2

There are four ways that a geo-point may be specified

From https://www.elastic.co/guide/en/elasticsearch/reference/5.0/geo-point.html


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.