My JSON (TMPOI_TEMPLATE)
{
"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"
}
My Mappings (TMPOI_MAPPING)
{
"trafficmeasurepoi": {
"properties": {
"addressInfo": {
"properties": {
"geopoint": { "type" : "geo_point" },
}
},
"poiLocation": {
"properties": {
"geopoint": { "type" : "geo_point" },
"speed": { "type" : "double"},
"date": { "type" : "date"}
}
}
}
}
}
My method to fill the index
Index is created by another method called createIndex(). Its working fine. But when i try to fill the index by following code i will get ERROR
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();
}
ERROR
MapperParsingException[failed to parse]; nested: IllegalStateException[Mixing up field types: class org.elasticsearch.index.mapper.core.StringFieldMapper$StringFieldType != class org.elasticsearch.index.mapper.internal.IdFieldMapper$IdFieldType on field _id];
_id is a reserved field. Try to remove the following line ("_id": "f212949c-7b67-45db-9f76-fe18bf951722") from the TMPOI_TEMPLATE and find another way to pass the document id. Hope it helps.
You'll need to delete _id
from the document itself.
来源:https://stackoverflow.com/questions/36982849/illegalstateexception-for-mixing-up-field-types