Elasticsearches通過坐標位置實現(xiàn)對附近人的搜索
更新時間:2022年04月19日 17:59:58 作者:Jeff的技術棧
這篇文章主要為大家介紹了Elasticsearches使用坐標位置實現(xiàn)對附近人的搜索,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
一 創(chuàng)建mapping
PUT test { "mappings": { "test":{ "properties": { "location":{ "type": "geo_point" } } } } }
二 導入數(shù)據(jù)
POST test/test { "location":{ "lat":12, "lon":24 } }
三 查詢
3.1根據(jù)給定兩個點組成的矩形,查詢矩形內的點
GET test/test/_search { "query": { "geo_bounding_box": { "location": { "top_left": { "lat": 28, "lon": 10 }, "bottom_right": { "lat": 10, "lon": 30 } } } } }
3.2根據(jù)給定的多個點組成的多邊形,查詢范圍內的點
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查詢距離范圍區(qū)間內的點的數(shù)量
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使用坐標位置實現(xiàn)對附近人的搜索 的詳細內容,更多關于Elasticsearches位置坐標搜索附近人的資料請關注腳本之家其它相關文章!
相關文章
ChatGPT平替-ChatGLM環(huán)境搭建與部署運行效果
這篇文章主要介紹了ChatGPT平替-ChatGLM環(huán)境搭建與部署運行,本節(jié)將介紹環(huán)境搭建與基本部署效果,結合實例代碼給大家介紹的非常詳細,需要的朋友可以參考下2023-05-05如何將服務器上的python代碼通過QQ發(fā)送回傳信息(附實現(xiàn)方法)
這篇文章主要介紹了我將服務器上的python代碼通過QQ發(fā)送回傳信息(附實現(xiàn)方法),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-05-05基于Laravel + Vue + Element 實現(xiàn) 人力資源系統(tǒng)(考勤應用 )
Bee 是人力資源系統(tǒng)中的考勤應用,主要功能用于員工申請假單。接下來通過本文給大家介紹基于Laravel + Vue + Element 考勤應用 之 人力資源系統(tǒng),需要的朋友可以參考下2019-10-10win10環(huán)境下使用Hyper-V進行虛擬機創(chuàng)建的教程(圖解)
這篇文章主要介紹了win10環(huán)境下使用Hyper-V進行虛擬機創(chuàng)建的教程,本文圖文詳解給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-11-11MyBatisCodeHelper-Pro插件破解版詳細教程[2.8.2]
MyBatisCodeHelper-Pro是IDEA下的一個插件,功能類似mybatis plugin。這篇文章給大家介紹MyBatisCodeHelper-Pro插件破解版[2.8.2]的相關知識,感興趣的朋友跟隨小編一起看看吧2020-09-09