elasticsearch - Elasticsearch错误的距离计算和过滤器

标签 elasticsearch

我正在对geo_distance过滤器使用elasticsearch,所以问题是它的距离测量很不正确,就像在下面的查询中一样,我正在过滤2500m,但返回的地方是6500m,为什么呢?我越过了谷歌 map 上两点之间的已验证距离。
询问

 
  "query": {
          "nested": {
            "path": "sellers",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "sellers.active": true
                    }
                  }
                ],
              "filter": {
        "geo_distance": {
          "distance": "226",
          "distance_type":"arc",
          "sellers.seller_geo": [ 31.0035008, 75.8480896]
        }
      }
              }
            },
            "inner_hits" : {
              
               "sort": [
          {
            "sellers.sale_price": "asc"
          }
        ],
        "size":1,
         "name": "hits_1"
            }
          }
        }
}


结果是
  "took" : 47,
  "hits" : {
    "hits" : [
      {
        "inner_hits" : {
          "hits_1" : {
            "hits" : {
              "total" : {
                "value" : 1,
                "relation" : "eq"
              },
              "max_score" : null,
              "hits" : [
                {
                  "_index" : "shopping_items",
                  "_type" : "_doc",
                  "_id" : "Z0AP8VFAEO",
                  "_nested" : {
                    "field" : "sellers",
                    "offset" : 22
                  },
                  "_score" : null,
                  "_source" : {
                    "prime" : true,
                    "instant_delivery" : true,
                    "dispatch_days" : 0,
                    "active" : true,
                    "cod" : false,
                    "discount" : "21.43",
                    "list_price" : 1964.25,
                    "seller_geo" : [
                      30.998450,
                      75.848835
                    ],
                    "postal_code" : 141001,
                    "sale_price" : 1964.25,
                    "seller_id" : "A07RE66FZA"
                  },
                  "sort" : [
                    1964.25
                  ]
                }
              ]
            }
          }
        }
      }
    ]
  }
}````
30.998450,75.848835和31.0035008,75.8480896之间的距离是9.34km

最佳答案

顺序为[30.998450, 75.848835]lat, lon是印度旁遮普邦的一个点。相反,它表示在北极圈附近的巴伦支海中的一个点...
现在,geo_distance query就像geo_point数据类型解析lon, lat这样的位置,从而符合GeoJSON标准。
换句话说,您的地理位置索引编制不正确。您可以通过删除索引并反转坐标来修复它。我个人更喜欢使用以下符号

{
  "lat":40,
  "lon":-70
}
这样人们就不会感到困惑。

关于elasticsearch - Elasticsearch错误的距离计算和过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63804249/

相关文章:

Elasticsearch - 使用 java api 获取源字段数据

symfony - 将带有Filebeat的symfony日志文件传输到本地docker-环境中的graylog

mongodb - 如何扩展定制的分析引擎?

elasticsearch - 如何忽略river mongodb和elasticsearch中的一些字段?

python - 通过python中的Elastic Search搜索唯一值

node.js - ElasticSearch 上的 mapper_parsing_exception 错误

elasticsearch - 当大量文档匹配时,elasticsearch ngram变慢

elasticsearch - 如何将 “updatedAt”时间戳添加到Elasticsearch文档

elasticsearch - Logstash-得到错误,因为发生未知错误,向Elasticsearch发送了批量请求

elasticsearch - Elasticsearch:按字段排序,最后带有custom_null值