我正在使用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