匹配所有对单个形状感兴趣的形状?

时间:2018-02-11 10:57:03

标签: elasticsearch geojson

我想查询哪些形状与ID为500的形状相交?我已根据此documentation创建了我的映射。我的查询基于此documentation。我的索引包含大约780个文档,并从文件中批量加载。

我创建索引和映射:

PUT lower_x

PUT lower_x/default/_mapping
{
  "properties": {
    "feature": {
      "type": "keyword"
    },
    "geometry": {
      "type": "geo_shape",
      "ignore_malformed": true
    },
    "name": {
      "type": "keyword"
    }
  }
}

成功批量加载我的GeoJSON ...我的查询:

GET lower_x/default/_search
{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": {
        "geo_shape": {
          "geometry": {
            "indexed_shape": {
              "index": "lower_x",
              "type": "default",
              "id": "500",
              "path": "geometry"
            },
            "relation": "intersects"
          }
        }
      }
    }
  }
}

错误:

{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to find geo_shape field [geometry]",
        "index_uuid": "9KlMVDyIR0C5Cb1mYQr85g",
        "index": "lower_x"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "lower_x",
        "node": "FgJ4CAIjScyNtDv_Mcpn_g",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to find geo_shape field [geometry]",
          "index_uuid": "9KlMVDyIR0C5Cb1mYQr85g",
          "index": "lower_x"
        }
      }
    ]
  },
  "status": 400
}

1 个答案:

答案 0 :(得分:0)

我正在使用elasticsearch的第5版,它不支持ignore_malformed属性。这就是问题所在。