繁体   English   中英

如何在弹性搜索中基于多个地理点搜索文档?

[英]How can i search documents based on multiple geopoints in elastic search?

我有一个用例,我想在其中搜索具有多个地理点的文档。

{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": {
        "geo_distance": {
          "distance": "100m",
          "nc_extraData.nc_geoPoint": {
            "lat": 21.36042723377568,
            "lon": -5.646749208228298
          }
        }
      }
    }
  }
} 

此查询仅支持单个地理点。 可能吗。

您可以添加多个具有不同地理点的geo_distance约束。 您还可以使用命名查询知道哪个点匹配:

{
  "query": {
    "bool": {
      "should": [
        {
          "geo_distance": {
            "distance": "100m",
            "nc_extraData.nc_geoPoint": {
              "lat": 21.36042723377568,
              "lon": -5.646749208228298
            },
            "_name": "point 1"
          }
        },
        {
          "geo_distance": {
            "distance": "100m",
            "nc_extraData.nc_geoPoint": {
              "lat": 22.36042723377568,
              "lon": -6.646749208228298
            },
            "_name": "point 2"
          }
        },
        {
          "geo_distance": {
            "distance": "100m",
            "nc_extraData.nc_geoPoint": {
              "lat": 23.36042723377568,
              "lon": -7.646749208228298
            },
            "_name": "point 3"
          }
        }
      ]
    }
  }
}
  "query": {
    "bool": {
      "should": [
        {
          "geo_distance": {
            "distance": "6000km",
            "nc_extraData.nc_geoPoint": {
              "lat": 39.783181787374076,
              "lon": -100.72051270885312
            },
            "_name": "point 1"
          }
        },
        {
          "geo_distance": {
            "distance": "6000km",
            "nc_extraData.nc_geoPoint": {
              "lat": 39.73750007106965,
              "lon": -90.00078544604122
            },
            "_name": "point 2"
          }
        },
         {
          "geo_distance": {
            "distance": "1000m",
            "nc_extraData.nc_geoPoint": {
              "lat": 60.73750007106965,
              "lon": -90.00078544604122
            },
            "_name": "point 3"
          }
        }
      ]
    }
  }
}```

I am trying this query. But the matching query contains both ``` "matched_queries": [
                    "point 2",
                    "point 1"
                ]``


暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM