gpt4 book ai didi

Elasticsearch Geoshape 查询错误结果

转载 作者:行者123 更新时间:2023-12-04 05:45:13 27 4
gpt4 key购买 nike

我在 ES 中有两个 geo_shapes。我需要弄清楚的是了解其中一个形状(绿色)是否包含另一个形状(红色)或与另一个形状(红色)相交的最佳方法。请参阅下面三种不同情况的直观表示:

情况一:很容易检测 - 使用绿色形状坐标进行 Geoshape 查询,其中“relation”=“within”

案例 II:也不是问题 - 使用绿色形状坐标进行 Geoshape 查询,其中“relation”=“INTERSECTS”

情况 III:是一个真正的问题 - 使用绿色形状坐标,我尝试使用“relation”=“INTERSECTS”进行 Geoshape 查询,结果返回红色形状......这是错误的 - 该形状不与彼此(我认为是这样)即使其中一侧相互接触......

有什么方法可以避免这里的误报结果吗?对于如何解决此任务还有其他建议吗?

附注坐标是精确的(例如:13.335594692338)。没有额外的映射,如树级别或精度...

enter image description here

最佳答案

使用 geoshape 存储在 Elasticsearch 中的每个多边形都会转换为字符串列表。为了缩小这个解释的范围,我假设您存储在 Elasticsearch 中的多边形使用 geohash 存储(这是 geoshape 类型的默认值)。

我不想讲太多细节,但看看这张图片

geohash

此描述取自 Elasticsearch 文档(详细信息不匹配,但您需要了解全局):

Geohashes divide the world into a grid of 32 cells—4 rows and 8 columns—each represented by a letter or number. The g cell covers half of Greenland, all of Iceland, and most of Great Britian. Each cell can be further divided into another 32 cells, which can be divided into another 32 cells, and so on. The gc cell covers Ireland and England, gcp covers most of London and part of Southern England, and gcpuuz94k is the entrance to Buckingham Palace, accurate to about 5 meters.

您的多边形被投影到矩形列表中,每个矩形都用一个字符串(geohash)表示。此投影的精度取决于树级别。我不知道 Elasticsearch 的默认树级别是多少,但如果您发现误报,那么它对您来说似乎太低了。

树级别为 8 splits the world in rectangles of size 38.2m x 19.1m。如果多边形的边缘穿过该矩形的中间,它可能会或可能不会(取决于实现)将此矩形的 geohash 表示分配给您的多边形。

要解决您的问题,您需要增加树级别以满足您的需求(有关映射 here 的更多信息)。请注意,尽管索引的大小会大大增加(也取决于形状的大小和复杂性)。作为一个示例,存储 1000 个区域大小的多边形(有些具有 100 个点),树级别为 8 - 索引大小约为 600-700MB。

请记住,无论您选择什么树级别,您总是面临一些误报的风险,因为 geohash 永远不会 100% 精确地表示您的形状。这是精度与性能之间的权衡,geohash 是性能明智的选择

关于Elasticsearch Geoshape 查询错误结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38880369/

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