Elasticsearch无法查询WKT

时间:2018-07-18 04:22:09

标签: sql elasticsearch logstash kibana wkt

我正在通过jdbc连接从MS sql server 2012检索几何数据,并将其推送到elasticsearch。数据表包括:对象标识和形状。 在Kibana中,数据如下所示。

  "objectid": 8,
     "untitled": "POLYGON ((16131003.104400001 -4962095.885400001, 16131161.300499998 -4962011.5243000016, 16130990.071999997 -4961961.9569999985, 16131003.104400001 -4962095.885400001))",

此处的“形状”字段以“无标题”显示,在映射上它以文本形式显示数据类型,

 "untitled": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }

我正在通过以下查询从Kibana查询数据,它提示我以下错误。

GET geo/_search
{
    "query": {
        "bool" : {
            "must" : {
                "match_all" : {}
            },
            "filter" : {
                "geo_polygon" : {
                    "untitled" : {
                        "points" : [
                        {"lat" : 16131003.104400001, "lon" : -4962095.885400001},
                        {"lat" : 16131161.300499998, "lon" : -4962011.5243000016},
                        {"lat" : 16130990.071999997, "lon" : -4961961.9569999985},
                        {"lat" : 16131003.104400001, "lon" : -4962095.885400001}
                        ]
                    }
                }
            }
        }
    }
}



  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "field [untitled] is not a geo_point field",
        "index_uuid": "WEVvAQgASeap6n1eyOZ54g",
        "index": "geo"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "geo",
        "node": "LuX-kU91RqqzKj-0DKFN6Q",
        "reason": {
          "type": "query_shard_exception",
          "reason": "field [untitled] is not a geo_point field",
          "index_uuid": "WEVvAQgASeap6n1eyOZ54g",
          "index": "geo"
        }
      }
    ]
  },
  "status": 400
}

如果能帮助我解决这个问题,我将不胜感激。

ps。我是Elasticsearch的新手,对于任何愚蠢的问题:(

欢呼

1 个答案:

答案 0 :(得分:0)

您需要将字段untitled的映射更改为geo shape

那么您应该可以使用geo shape query