【发布时间】:2014-09-05 08:40:22
【问题描述】:
我正在使用 Elasticsearch 的 NEST 客户端库为特定类型创建索引。
该类型包含三个string 属性加上一个用于保存geo_shape 类型(特别是用于envelope 形状)。
问题是,生成的请求在 ES 中解析失败:
{
"error": "MapperParsingException[mapping [layer]]; nested: MapperParsingException[No handler for type [point] declared on field [boundingBox]]; ",
"status": 400
}
生成此错误消息的 NEST 构建的请求是:
POST /metadata
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"layer": {
"_all": {
"enabled": false
},
"properties": {
"namespace": {
"type": "string"
},
"name": {
"type": "string"
},
"abstract": {
"type": "string"
},
"boundingBox": {
"type": "point",
"tree": "geohash",
"tree_levels": 2,
"distance_error_pct": 0.025
}
}
}
}
}
我发现唯一阻止此请求成功的是boundingBox 属性的type 声明,它的值应该是geo_shape 而不是point。
这里是用于执行调用的 C# 代码:
ElasticClient client = new ElasticClient(settings);
IIndicesOperationResponse response = client.CreateIndex(c => c
.Index("metadata")
.NumberOfShards(1)
.NumberOfReplicas(0)
.AddMapping<ESLayer>(m => m
.Type("layer")
.AllField(a => a.Enabled(false))
.Properties(p => p
.String(x => x.Name(n => n.Namespace))
.String(x => x.Name(n => n.Name))
.String(x => x.Name(n => n.Abstract))
.GeoShape(x => x
.Name(n => n.BoundingBox)
.Tree(GeoTree.Geohash)
.TreeLevels(2)
.DistanceErrorPercentage(0.025)))));
还有ESLayer 类:
private class ESLayer
{
public string Namespace { get; set; }
public string Name { get; set; }
public string Abstract { get; set; }
public EnvelopeGeoShape BoundingBox { get; set; }
}
请注意,我使用 NEST 附带的 EnvelopeGeoShape 类来表示边界框属性。
Elasticsearch 版本:1.3.1
NEST 版本:1.0.2
关于我可能遗漏什么的任何线索?
【问题讨论】:
标签: c# elasticsearch nest