elasticsearch 如果点(商家)在Elasticsearch中使用不同的半径,那么在点(用户)周围查找可用点(商家)的最佳方法是什么
对于这个问题,我使用了elasticsearch 如果点(商家)在Elasticsearch中使用不同的半径,那么在点(用户)周围查找可用点(商家)的最佳方法是什么,elasticsearch,geometry,elasticsearch,Geometry,对于这个问题,我使用了geo_shape,想知道是否有其他更好(更快)的方法来解决这个问题,ES版本是6.5 映射: { "index": { "mappings": { "merchant": { "_all": { "enabled": false
geo_shape
,想知道是否有其他更好(更快)的方法来解决这个问题,ES版本是6.5
映射:
{
"index": {
"mappings": {
"merchant": {
"_all": {
"enabled": false
},
"properties": {
"delivery_circle": {
"type": "geo_shape",
"tree": "quadtree",
"precision": "50.0m",
"distance_error_pct": 0.025
}
}
}
}
}
}
文档示例:
{
"_source": {
"id": 1,
"delivery_circle": {
"coordinates": [ // merchant location, its radius is 4km
123.456,
1.2345
],
"radius": "4000m",
"type": "circle"
}
}
}
{
"_source": {
"id": 2,
"delivery_circle": {
"coordinates": [ // merchant location, its radius is 5km
123.567,
1.3456
],
"radius": "5000m",
"type": "circle"
}
}
}
搜索查询示例:
{
"query": {
"bool": {
"filter": [
{
"geo_shape": {
"delivery_circle": {
"relation": "contains",
"shape": {
"coordinates": [ // user location
123,
1
],
"type": "point"
}
}
}
}
]
}
}
}
这是非主题的建议,但是你也可以考虑使用GeHAHASH。这可以降低搜索时间的复杂性。
geoshape查询是为此类任务而设计的,您应该可以。