1.构建schema
.startObject("location").field("type", "geo_point").endObject()
2.构建索引
.field("location", geoMap.get("lat") + "," + geoMap.get("lon"))
3.搜索api
TransportClient client = ESClientFactory.instance().transportClient();
SearchRequestBuilder searchRequestBuilder = client.prepareSearch("geo")
.setTypes("geo")
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setExplain(false);
GeoDistanceQueryBuilder location = QueryBuilders.geoDistanceQuery("location")
.point(lat, lon)
.distance(d, DistanceUnit.KILOMETERS);
searchRequestBuilder.setPostFilter(location);
// 获取