ES的地理位置查询
1、背景
店铺有实体类,在地图上搜索显示当前位置附近店铺,并显示距当前位置距离;当前位置由前端传参(经度与纬度)。
比如我们有很多的4s店,给用户一个app,在某个地方的时候,可以根据当前的地理位置搜索一下,自己附近的4s店。
(刚学会代码实现,做个笔记,原理和源码暂时没研究)
2、代码示例
/**
* @description: 门店实体
**/
@Getter
@Setter
@Document(indexName = ESIndexAndType.INDEX_NAME)
public class StoreES {
@Id
private String id;
private String storeName;
//经度
private Double longitude;
//纬度
private Double latitude;
private Boolean isdelete;
//地址
private String address;
@GeoPointField
private GeoPoint location;
}
/**
* @Description:位置信息入参类
**/
@Getter
@Setter
public class LocationModel {
//经度
private Double lo