# MapperParsingException: 解析 geo_shape 字段 [location] 失败 - 期望 [point] 但找到 [polygon]

- **ID:** `elasticsearch/geo-shape-indexing-error`
- **领域:** elasticsearch
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 87%

## 根因

索引映射将字段定义为点类型，但索引文档包含多边形或其他几何类型，导致解析不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.10.0 | active | — | — |
| 7.17.0 | active | — | — |
| 8.0.0 | active | — | — |
| 8.7.0 | active | — | — |

## 解决方案

1. ```
   Update the mapping to accept multiple geometry types by setting `'ignore_malformed': true` for the field: PUT my_index/_mapping { "properties": { "location": { "type": "geo_shape", "ignore_malformed": true } } }
   ```
2. ```
   Change the mapping to the correct geometry type (e.g., polygon) and reindex: PUT my_index/_mapping { "properties": { "location": { "type": "geo_shape", "orientation": "right" } } }
   ```
3. ```
   Use a pipeline to transform the geometry before indexing: PUT _ingest/pipeline/geo_transform { "processors": [ { "geo_shape": { "field": "location", "target_field": "location", "shape_type": "polygon" } } ] }
   ```

## 无效尝试

- **** — The mapping must explicitly define the geometry type (e.g., 'point', 'polygon') for validation. Omitting it can lead to unexpected behavior or performance issues. (50% 失败率)
- **** — This loses spatial precision and may not be acceptable for queries that require exact geometry. It also requires code changes. (30% 失败率)
- **** — This is disruptive to production and may cause data loss if not backed up. It also doesn't fix the immediate indexing error. (60% 失败率)
