一 创建mapping
put test { "mappings": { "test":{ "properties": { "location":{ "type": "geo_point" } } } } }
二 导入数据
post test/test { "location":{ "lat":12, "lon":24 } }
三 查询
3.1根据给定两个点组成的矩形,查询矩形内的点
get test/test/_search { "query": { "geo_bounding_box": { "location": { "top_left": { "lat": 28, "lon": 10 }, "bottom_right": { "lat": 10, "lon": 30 } } } } }
3.2根据给定的多个点组成的多边形,查询范围内的点
get test/test/_search { "query": { "geo_polygon": { "location": { "points": [ { "lat": 11, "lon": 25 }, { "lat": 13, "lon": 25 }, { "lat": 13, "lon": 23 }, { "lat": 11, "lon": 23 } ] } } } }
3.3查询给定1000km距离范围内的点
get test/test/_search { "query": { "geo_distance": { "distance": "1000km", "location": { "lat": 12, "lon": 23 } } } }
3.4查询距离范围区间内的点的数量
get test/test/_search { "size": 0, "aggs": { "myaggs": { "geo_distance": { "field": "location", "origin": { "lat": 52.376, "lon": 4.894 }, "unit": "km", "ranges": [ { "from": 50, "to": 30000 } ] } } } }
以上就是elasticsearches使用坐标位置实现对附近人的搜索 的详细内容,更多关于elasticsearches位置坐标搜索附近人的资料请关注<计算机技术网(www.ctvol.com)!!>其它相关文章!
需要了解更多python教程分享Elasticsearches通过坐标位置实现对附近人的搜索,都可以关注python教程分享栏目—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/pythontutorial/1086150.html