--- title: "Shape类型未包含 - 如何解决此Elasticsearch异常" date: 2026-01-04 lastmod: 2026-01-04 description: "Elasticsearch在尝试索引包含shape字段的文档时,如果未指定shape类型会抛出异常。本文介绍如何解决此问题。" tags: ["Shape类型", "异常处理", "地理数据", "索引映射", "Elasticsearch错误"] summary: "版本: 6.8-8.9 简而言之,当Elasticsearch尝试索引包含shape字段的文档时,如果未指定shape类型,就会发生此错误。这对于Elasticsearch理解shape的几何形状是必需的。要解决此问题,您可以在映射中指定shape类型,或者在要索引的文档中包含它。例如,如果您正在索引多边形,应该在文档中包含"type": “polygon”。或者,您可以在创建索引时在映射中指定shape类型。 日志上下文 # “shape type not included"日志的类名是 GeoJsonParser.java。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: } if (malformedException != null) { throw new ElasticsearchParseException(malformedException); } else if (shapeType == null) { throw new ElasticsearchParseException("shape type not included"); } else if (coordinateNode == null && GeoShapeType.GEOMETRYCOLLECTION != shapeType) { throw new ElasticsearchParseException("coordinates not included"); } else if (geometryCollections == null && GeoShapeType.GEOMETRYCOLLECTION == shapeType) { throw new ElasticsearchParseException("geometries not included"); } else if (radius !" --- > **版本:** 6.8-8.9 简而言之,当Elasticsearch尝试索引包含shape字段的文档时,如果未指定shape类型,就会发生此错误。这对于Elasticsearch理解shape的几何形状是必需的。要解决此问题,您可以在映射中指定shape类型,或者在要索引的文档中包含它。例如,如果您正在索引多边形,应该在文档中包含"type": "polygon"。或者,您可以在创建索引时在映射中指定shape类型。 ## 日志上下文 "shape type not included"日志的类名是[GeoJsonParser.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java } if (malformedException != null) { throw new ElasticsearchParseException(malformedException); } else if (shapeType == null) { throw new ElasticsearchParseException("shape type not included"); } else if (coordinateNode == null && GeoShapeType.GEOMETRYCOLLECTION != shapeType) { throw new ElasticsearchParseException("coordinates not included"); } else if (geometryCollections == null && GeoShapeType.GEOMETRYCOLLECTION == shapeType) { throw new ElasticsearchParseException("geometries not included"); } else if (radius != null && GeoShapeType.CIRCLE != shapeType) { ```