Elasticsearch 7.6版丢失Geoshape时出错



我们有一个具有GeoShape类型字段的Index。如果我们进行包括该字段的查询,而该字段丢失,则会得到错误:

**Type: illegal_state_exception Reason: "Shape with name [34219995] found but missing geometry field"**

在其他类型可能为空的情况下,是否有任何方法可以将默认值分配给地理图形字段?

我们使用的查询是:(使用NEST api(:

filters.Add(fq => fq.Term(t => t.Field(f => f.LocalityId).Value(34219995)) || fq.GeoShape(g => g.Field("locationShape").Relation(GeoShapeRelation.Within).IndexedShape(f => f.Id(34219995).Index("GeoshapesIndex").Path("geometry")))); 

如果"GeoshapesIndex"中的字段丢失,我们会得到错误。

"ignore_malformed": true添加到字段的映射中应该可以从一开始就防止查询此类形状。请注意,您必须重新索引才能使其生效。

其次,尝试将ignore_unmapped添加到geo_shape查询中:

GET geoindex/_search
{
"query": {
"geo_shape": {
"ignore_unmapped": true,
"polygon": {
"shape": {
"type": "point",
"coordinates": [
0.5,
0.5
]
},
"relation": "within"
}
}
}
}

最新更新