我们有一个索引,它有一个GeoShape类型的字段。如果我们的查询包含这个字段,但是缺少这个字段,我们会得到这样的错误:
**Type: illegal_state_exception Reason: "Shape with name [34219995] found but missing geometry field"**有没有办法给geoshape字段分配默认值,就像在其他类型可能为空的情况下一样?
我们使用的查询是:(使用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“中的字段丢失,我们会得到错误信息。
发布于 2020-05-01 23:24:26
将"ignore_malformed": true添加到字段的映射中应该可以在一开始就防止查询这样的形状。但请注意,您必须重新编制索引才能使其生效。
其次,尝试在geo_shape查询中添加ignore_unmapped:
GET geoindex/_search
{
"query": {
"geo_shape": {
"ignore_unmapped": true,
"polygon": {
"shape": {
"type": "point",
"coordinates": [
0.5,
0.5
]
},
"relation": "within"
}
}
}
}https://stackoverflow.com/questions/61544091
复制相似问题