最近用String封装了经纬度坐标点,一切都ok;然后尝试用对象封装;但是存储在es里边的都是对象内存地址,而不是属性值对应的经纬度。我该怎么做?代码如下:
MapLocation locations = new MapLocation();
locations.setLat(116.4072154982);
locations.setLon(39.9047253699);
Map<String, Object> map = new HashMap<>();
String id = "1";
map.put("name","一号");
map.put("age",18);
map.put("locations",locations);
map.put("school","中南大学");
String saveDoc = clientUtil.saveDoc("girlfriend", "gf_gentle", id, map);
这样存储后,es显示的时对象的地址值,而不是类似:
{
“location”:{
"lat":"116.4072154982",
"lon":"39.9047253699"
}
}
我该怎么处理,才可以在es里边展示经纬度数据?
MapLocation locations = new MapLocation();
locations.setLat(116.4072154982);
locations.setLon(39.9047253699);
Map<String, Object> map = new HashMap<>();
String id = "1";
map.put("name","一号");
map.put("age",18);
map.put("locations",locations);
map.put("school","中南大学");
String saveDoc = clientUtil.saveDoc("girlfriend", "gf_gentle", id, map);
这样存储后,es显示的时对象的地址值,而不是类似:
{
“location”:{
"lat":"116.4072154982",
"lon":"39.9047253699"
}
}
我该怎么处理,才可以在es里边展示经纬度数据?
2 个回复
JackGe
赞同来自: xuewb_1024 、CarrieJin
.startObject()
.field("name", "一号")
.field("age", 18)
.field("school", "中南大学")
.startObject("locations").field("lat", 116.4072154982)
.field("lon", 39.9047253699)
.endObject();
prepareBulk.add(client.prepareIndex(index, type).setSource(xContentBuilder));
yayg2008
赞同来自: