2014-09-04 73 views
2

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

我發現的唯一的保持該請求不成功的東西是typeboundingBox屬性的聲明,該屬性的值應爲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

什麼我可能會丟失任何線索?

回答

2

這是肯定的一個bug;很好的捕獲。我剛剛爲此發佈了問題#925並推送了一個修復程序。它將包含在下一個版本(1.1.0)中,我們計劃很快就會發布。同時,您可以從我們的CI構建中獲取NuGet包:https://www.myget.org/gallery/elasticsearch-net

+0

謝謝@Greg,很高興聽到!一旦它發佈,我將立即切換到下一個版本。與此同時,我想測試每晚的構建,但myget似乎現在正在下降。包的任何其他來源? – Chopin 2014-09-05 18:17:26

+0

Myget似乎工作正常,至少對我而言。唯一的其他選擇是克隆GitHub倉庫並編譯解決方案。 – 2014-09-05 18:35:15

+0

我試過編譯源代碼,它工作。今天也嘗試訪問myget,現在爲我工作。乾杯! – Chopin 2014-09-08 15:04:14

0

ES中沒有類型的點。根據您的要求,您應該使用'geo_point'或'geo_shape'。

看到: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html

也: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html

編輯:您正在使用的映射選項都是爲了geo_shape型

+0

謝謝,我意識到這一點。但我並不是通過手動將請求寫入ES,而是通過NEST庫。我的問題更多地是關於用於創建索引的.NET代碼,如果它缺少一些東西,或者我正面臨NEST錯誤。 – Chopin 2014-09-04 21:35:37