我正在使用Elasticsearch的NEST客户端库为特定类型创建索引。使用geoshape属性映射创建索引
该类型包含三个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
}
}
}
}
}
我发现的唯一的保持该请求不成功的东西是type
boundingBox
属性的声明,该属性的值应为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
什么我可能会丢失任何线索?
谢谢@Greg,很高兴听到!一旦它发布,我将立即切换到下一个版本。与此同时,我想测试每晚的构建,但myget似乎现在正在下降。包的任何其他来源? – Chopin 2014-09-05 18:17:26
Myget似乎工作正常,至少对我而言。唯一的其他选择是克隆GitHub仓库并编译解决方案。 – 2014-09-05 18:35:15
我试过编译源代码,它工作。今天也尝试访问myget,现在为我工作。干杯! – Chopin 2014-09-08 15:04:14