--- title: "Points only 不能为 term 策略设置为 false – 如何解决此 Elasticsearch 异常" date: 2026-01-19 lastmod: 2026-01-19 description: "当尝试为使用 term 策略的 geo_shape 字段将 points_only 参数设置为 false 时,Elasticsearch 会抛出此异常。term 策略仅支持点形状,因此会导致错误。" tags: ["Elasticsearch", "geo_shape", "映射错误", "空间策略"] summary: "版本: 6.8-7.1 简而言之,当你在 Elasticsearch 中为使用 “term” 策略的 geo_shape 字段尝试将 “points_only” 参数设置为 false 时,会发生此错误。term 策略仅支持点形状,因此会报错。要解决此问题,你可以将策略更改为支持各种形状的 “recursive” 或 “vector”,或者如果你想继续使用 “term” 策略,请确保你的 geo_shape 字段仅包含点形状。 日志上下文 # 日志 “points_only cannot be set to false for term strategy” 的类名是 LegacyGeoShapeFieldMapper.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: this.precision = precision; } public void setPointsOnly(boolean pointsOnly) { if (this.strategy == SpatialStrategy.TERM && pointsOnly == false) { throw new ElasticsearchParseException("points_only cannot be set to false for term strategy"); } this." --- > **版本:** 6.8-7.1 简而言之,当你在 Elasticsearch 中为使用 "term" 策略的 geo_shape 字段尝试将 "points_only" 参数设置为 false 时,会发生此错误。term 策略仅支持点形状,因此会报错。要解决此问题,你可以将策略更改为支持各种形状的 "recursive" 或 "vector",或者如果你想继续使用 "term" 策略,请确保你的 geo_shape 字段仅包含点形状。 日志上下文 ----------- 日志 "points\_only cannot be set to false for term strategy" 的类名是 [LegacyGeoShapeFieldMapper.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java this.precision = precision; } public void setPointsOnly(boolean pointsOnly) { if (this.strategy == SpatialStrategy.TERM && pointsOnly == false) { throw new ElasticsearchParseException("points_only cannot be set to false for term strategy"); } this.pointsOnly = pointsOnly; } public void setDistanceErrorPct(double distanceErrorPct) { ```