elasticsearch - Elasticsearch geo_distance过滤器-距离单位设置为km,但似乎以米为单位进行计算

标签 elasticsearch

我正在使用geo_distance过滤器来获取距引用点一定距离内的点。作为distance_unit,我设置了km,但是,当我运行代码时,我很确定Elastic会计算米,而不是公里(因此在下面的这种特殊情况下,我得到的点在20米而不是20公里之内) 。

有什么想法为什么要用米而不是公里?

{
    "query": {
        "filtered": {
            "query": {
                "bool": {
                    "must_not": [
                        {
                            "term": {
                                "_id": {
                                    "value": idnum
                                }
                            }
                        }
                    ]
                }
            },
            "filter": {
                "geo_distance": {
                    "distance": 20,
                    "distance_unit": "km",
                    "geopoint": {
                        "lat": lat,
                        "lon": lng
                    }
                }
            }
        }
    }
}

最佳答案

使用"distance": "20KM", rather than distance_unit....

关于elasticsearch - Elasticsearch geo_distance过滤器-距离单位设置为km,但似乎以米为单位进行计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23080760/

相关文章:

elasticsearch - Elasticsearch:multi_match对过滤器无效

elasticsearch - Index = true的属性关键字在搜索中失败

r - 对相似的词进行分组

java - 通过Java API进行Elasticsearch查询

java - 可以使用复合键制作 spring-data-elasticsearch @Document 吗?

Elasticsearch:如何在不删除整个索引的情况下删除映射类型?

ruby-on-rails - Elasticsearch + 轮胎 + PaperClip : Nested objects

json - 通过talend上的REST请求发送json数据

java - 尝试使用 Java High Level REST Client 查询 Long 类型时出现问题

elasticsearch - 在Elasticsearch中为文档建立索引时会创建什么索引