【问题标题】:Elasticsearch - seach document with geo_shape based on other document geo_shapeElasticsearch - 基于其他文档 geo_shape 使用 geo_shape 搜索文档
【发布时间】:2017-02-15 20:31:29
【问题描述】:

是否有一个选项可以像这样在 ElasticSearch 中使用一个查询来执行搜索:

  1. 获取 ID = 1 的文档
  2. 此文档有一个带有 geo_shape 映射的字段
  3. 从该字段中获取值
  4. 搜索 geo_shape 字段与 doc(id=1) geo_shape 相交的其他文档
  5. 返回找到的文档

【问题讨论】:

    标签: elasticsearch geojson elasticsearch-geo-shape


    【解决方案1】:

    是的,您可以为此目的使用pre-indexed shapes

    POST /_search
    {
        "query": {
            "bool": {
                "must": {
                    "match_all": {}
                },
                    "filter": {
                        "geo_shape": {
                            "your_shape_field": {
                                "indexed_shape": {
                                    "id": "1",
                                    "type": "your_type",
                                    "index": "your_index",
                                    "path": "shape"
                                },
                                "relation": "intersects"
                            }
                        }
                    }
            }
        }
    }
    

    此查询将返回所有具有 your_shape_field 与 ID 为 1 的文档中的 shape 字段相交的文档。

    【讨论】:

    • 这太棒了!非常感谢!
    猜你喜欢
    • 2020-08-04
    • 1970-01-01
    • 1970-01-01
    • 2013-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-22
    • 2021-05-20
    相关资源
    最近更新 更多