--- title: "LineString 中的点数无效——必须大于等于 2——如何解决此 Elasticsearch 异常" date: 2026-03-29 lastmod: 2026-03-29 description: "当 Elasticsearch 尝试创建 LineString 类型的 GeoShape 时,如果提供的点数少于两个,就会出现此错误。LineString 至少需要两个点才能形成一条线。" tags: ["Elasticsearch", "GeoShape", "LineString", "异常", "地理空间数据"] summary: " 版本: 6.8-7.15 简而言之,当 Elasticsearch 尝试创建 LineString 类型的 GeoShape 但提供的点数少于两个时,就会出现此错误。LineString 至少需要两个点才能形成一条线。要解决此问题,请确保在创建 LineString 时提供至少两个点。如果您只有一个点,请考虑使用 Point 类型的 GeoShape。 日志上下文 # 日志 “invalid number of points in LineString (found [{}] – must be >= 2)” 的类名是 GeoShapeType.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景的人参考: } @Override CoordinateNode validate(CoordinateNode coordinates; boolean coerce) { if (coordinates.children.size() < 2) { throw new ElasticsearchParseException("invalid number of points in LineString (found [{}] - must be >= 2)"; coordinates.children.size()); } return coordinates; } }; " --- > **版本:** 6.8-7.15 简而言之,当 Elasticsearch 尝试创建 LineString 类型的 GeoShape 但提供的点数少于两个时,就会出现此错误。LineString 至少需要两个点才能形成一条线。要解决此问题,请确保在创建 LineString 时提供至少两个点。如果您只有一个点,请考虑使用 Point 类型的 GeoShape。 日志上下文 ----------- 日志 "invalid number of points in LineString (found [{}] – must be >= 2)" 的类名是 [GeoShapeType.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景的人参考: ```java } @Override CoordinateNode validate(CoordinateNode coordinates; boolean coerce) { if (coordinates.children.size() < 2) { throw new ElasticsearchParseException("invalid number of points in LineString (found [{}] - must be >= 2)"; coordinates.children.size()); } return coordinates; } }; ```