I am using ElasticSearch and JAVA REST High Level Client v7.9
Following is my agent class
public class Agent {
private GeoPoint location;
private long timestamp;
private long available;
public Agent(GeoPoint location, long timestamp) {
this.location = location;
this.timestamp = timestamp;
available = 0;
}
}
As you can see Im using a GeoPoint field. I want to map this as geo_point
field of elasticserch.
When I check the mapping in postman I see the following output
GET localhost:9200/agents/_mapping
"agents": {
"mappings": {
"properties": {
"available": {
"type": "long"
},
"location": {
"properties": {
"lat": {
"type": "float"
},
"lon": {
"type": "float"
}
}
},
"timestamp": {
"type": "long"
}
}
}
}
However when I first create a mapping for my index
PUT localhost:9200/agents/_mapping
"properties" : {
"location" : { "type" : "geo_point"},
"timestamp" : { "type" : "long"},
"available" : { "type" : "long"}
}
I get the expected output as below
"agents": {
"mappings": {
"properties": {
"available": {
"type": "long"
},
"location": {
"type": "geo_point"
},
"timestamp": {
"type": "long"
}
}
}
}
As mappings are now deprecated, I want to understand what is the issue here. I am adding java objects to elasticsearch by converting them to json strings. The mapping is automatically created for other datatypes but it is unable to read geo_point fields.