gpt4 book ai didi

elasticsearch - Elasticsearch查找距一组引用点最远距离的位置

转载 作者:行者123 更新时间:2023-12-02 23:45:30 25 4
gpt4 key购买 nike

我需要帮助进行查询,以便使用Elasticsearch查找距某些引用点不到1000米的地方。 I.E .:哪些药房距离用户定义的地铁站不到1000米。我有他们的经度和纬度值。

我在elasticsearch上找到了这种搜索类型的一些示例,但所有示例都在考虑过滤器(硬编码的lat和lng)上的一组静态引用点。

添加更多信息:

GET /places
{
"places" : {
"aliases" : { },
"mappings" : {
"properties" : {
"location" : {
"type" : "geo_point"
},
"name" : {
"type" : "text"
}
}
}
}

GET /references
{
"references" : {
"aliases" : { },
"mappings" : {
"properties" : {
"location" : {
"type" : "geo_point"
},
"name" : {
"type" : "text"
}
}
}
}

我试图创建一个搜索请求,在这里我可以根据引用索引上的文档列表来选择场所索引上的文档。大多数示例仅演示如何搜索这样的文档:
GET /places/_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "1000m",
"pin.location" : {
"lat" : 40,
"lon" : -70
}
}
}
}
}
}

上面示例中的值pin.location / origin是固定的,但是我需要基于引用索引。

在MySQL中应该是这样的:
select pl.latitude, pl.longitude from places as pl
where exists (
select rf.id from references as rf where ST_Distance_Sphere(
point(pl.longitude, pl.latitude),
point(rf.longitude, rf.latitude)
) < 1000 and rf.name = "subway"
) and pl.name = "drugstore"

最佳答案

AFAIK不幸的是,ES中没有替代ST_Distance_Sphere的选项。

是否需要重新考虑数据结构的方式-也许每个n的最近place机构?说5公里然后,如果用户要求<= 1km,则可以滤除距离太远的距离。

地铁站/药店/等大多是固定的位置(从字面上和象征意义上来说)。他们不经常更改property / geoloc / etc。当他们这样做时,只需对附近的每个地方进行简单更新即可解决问题。

关于elasticsearch - Elasticsearch查找距一组引用点最远距离的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61576765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com