geojson到Elasticsearch:无法细分形状

2024-04-29 16:41:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在将一些geojson文件(大约4000~5000个多多边形特征)索引到Elasticsearch中

下面是映射

"mappings": {
       "properties": {
      "type": {
        "type": "keyword"
      },
      "properties": {
        "type": "object"
      },
      "geometry": {
        "type": "geo_shape"
      }
       }
    }

我的索引代码如下所示:

helpers.bulk(es, k, chunk_size=500, request_timeout=1000)

索引操作(在区块中)被以下错误消息停止:

{'type': 'mapper_parsing_exception', 'reason': 'failed to parse field [geometry] of type [geo_shape]', 'caused_by': {'type': 'illegal_argument_exception', 'reason': 'Unable to Tessellate shape

此错误的原因是什么?
在索引geojson文件时,是否可以忽略此错误


Tags: 文件togeojsontype错误exception特征properties
3条回答

我不确定这个错误是否是由输入文件中一些复杂的多重多边形引起的

然而,受以下帖子的启发,我将多个多边形转换为单个多边形后,我成功地吸收了所有形状,没有任何错误:)

https://gist.github.com/mhweber/cf36bb4e09df9deee5eb54dc6be74d26

您的geojson语法正确&;有效的现在,您只需确保正确索引多重多边形:

PUT demo_l08_bs
{
  "mappings": {
    "properties": {
      "geometry": {
        "type": "geo_shape"
      }
    }
  }
}

索引geojson,不更改任何内容:

POST demo_l08_bs/_doc
{
  "properties": {
    ...
  },
  "geometry": {
    "type": "MultiPolygon",
    "coordinates": [...]
  }
}

验证点是否位于其中:

GET demo_l08_bs/_search
{
  "query": {
    "geo_shape": {
      "geometry": {
        "shape": {
          "type": "point",
          "coordinates": [
            151.14646911621094,
            -33.68463933764522
          ]
        },
        "relation": "intersects"
      }
    }
  }
}

enter image description here

我研究了这个问题,发现多边形是有效的,并且发现了Lucene tessellator中的一个bug。我提出了一个问题:

https://issues.apache.org/jira/browse/LUCENE-9417

修复方法如下:

https://github.com/apache/lucene-solr/pull/1614

相关问题 更多 >