2016-05-02 30 views
1

我的JSON(TMPOI_TEMPLATE)IllegalStateException異常爲字段類型混合起來

{ 
"addressInfo": { 
    "geopoint": { 
     "lon": 48.845877, 
     "lat": 8.821861, 
    } 
}, 
"poiLocation": { 
    "geopoint": { 
     "lon": 48.845877, 
     "lat": 8.821861, 
    }, 
    "speed": 3.0, 
    "date": 1461067375605 
}, 
"_id": "f212949c-7b67-45db-9f76-fe18bf951722" 
} 

我的映射(TMPOI_MAPPING)

{ 
"trafficmeasurepoi": { 
     "properties": { 
     "addressInfo": { 
      "properties": { 
       "geopoint": { "type" : "geo_point" }, 
      } 
     }, 
     "poiLocation": { 
      "properties": { 
       "geopoint": { "type" : "geo_point" }, 
       "speed": { "type" : "double"}, 
       "date": { "type" : "date"} 
      } 
     } 
    } 
    } 
} 

我的方法來填充

指數由被稱爲另一種方法創建的索引createIndex()。它的工作正常。但是當我試圖填補下面的代碼索引我會得到錯誤

private void fillIndex() 
{ 
    // fill index with tmpoi data 
    Map<String, Object> tmpoi = JsonLoaderUtil.loadJson(TMPOI_TEMPLATE); 
    String tmPoiId = (String) tmpoi.get("_id"); 
    IndexRequestBuilder req = client.prepareIndex(INDEX_NAME, TMPOI_TYPE, tmPoiId).setSource(tmpoi); 
    req.setRefresh(true); 
    IndexResponse res = req.execute().actionGet(); 
} 

錯誤

MapperParsingException [無法解析]嵌套:IllegalStateException [混合字段類型:類org.elasticsearch.index.mapper.core.StringFieldMapper $ StringFieldType!= class org.elasticsearch.index.mapper.internal.IdFieldMapper $ IdFieldType on field _id];

回答

1

您需要從文檔本身刪除_id

1

_id是一個保留字段。嘗試從TMPOI_TEMPLATE中刪除以下行(「_id」:「f212949c-7b67-45db-9f76-fe18bf951722」),並找到另一種傳遞文檔ID的方法。 希望它有幫助。

相關問題