【问题标题】:Elasticsearch 2.3 Geo Shape type mappingElasticsearch 2.3 Geo Shape 类型映射
【发布时间】:2016-10-28 11:14:59
【问题描述】:

我在 Elasticsearch 索引中有一个具有以下映射的字段

   "cluster_boundary": {
        "type": "geo_shape",
        "tree": "quadtree",
        "precision": "1mm"
    }

但是当我将此映射放入弹性搜索索引时,我收到以下错误

java.lang.IllegalArgumentException: maxLevels of 36 exceeds limit of 29
     at org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree.<init>(PackedQuadPrefixTree.java:70)
     at org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper$GeoShapeFieldType.freeze(GeoShapeFieldMapper.java:276)
     at org.elasticsearch.index.mapper.FieldMapper.<init>(FieldMapper.java:289)
     at org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper.<init>(GeoShapeFieldMapper.java:428)
     at org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper$Builder.build(GeoShapeFieldMapper.java:160)
     at org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper$Builder.build(GeoShapeFieldMapper.java:119)
     at org.elasticsearch.index.mapper.object.ObjectMapper$Builder.build(ObjectMapper.java:167)
     at org.elasticsearch.index.mapper.DocumentMapper$Builder.<init>(DocumentMapper.java:88)
     at org.elasticsearch.index.mapper.MapperBuilders.doc(MapperBuilders.java:44)
     at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:118)
     at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:99)
     at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:498)
     at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.applyRequest(MetaDataMappingService.java:257)
     at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.execute(MetaDataMappingService.java:230)
     at org.elasticsearch.cluster.service.InternalClusterService.runTasksForExecutor(InternalClusterService.java:468)
     at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:772)
     at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:231)
     at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:194)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
     at java.lang.Thread.run(Thread.java:745)

如果我将quadtree 更改为geohash 它可以工作。并且,根据elasticsearch,quadtree 中允许的最大树级别是50

【问题讨论】:

    标签: elasticsearch geospatial quadtree


    【解决方案1】:

    PackedQuadPrefixTree 的最高等级为 29,而QuadPrefixTree 的最高等级为 50。您可以检查herehere

    我查看了 ES source codequadtree 映射到 lucene PackedQuadPrefixTree,因此您必须将精度值降低到 1m,即转换为 26 个 tree_levels,或者您可以使用最多 50 个级别的 legacyquadtree

    我注意到的一件事是,如果您使用 legacyquadtree 指定非常多的级别而不是说最大允许级别是 50,则 ES 会抛出 out of memory error

    PUT test_index/_mapping/test_type
    {
      "properties": {
        "test": {
          "type": "geo_shape",
          "tree": "legacyquadtree",
          "tree_levels": "54354552"
        }
      }
    }
    

    理想情况下,上面的代码应该说最大级别为 50,但它会耗尽堆空间并引发 OOM 错误。

    我也认为 1mm 太精确了,即使使用 leagcyquadtree 也会占用大量内存。 More 对此。我还在 github 上开了一个issue,你可以关注。

    【讨论】:

    • 感谢您的回复。根据 elasticsearch 文档quadtree 最多有 50 个级别。根据您所说,文档似乎是错误的。我会尝试使用legacyquadtree。我试过1m精度,树级别是33
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 2014-03-10
    • 2016-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多