IllegalStateException用于混淆字段类型 [英] IllegalStateException for mixing up field types

查看:206
本文介绍了IllegalStateException用于混淆字段类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的JSON(TMPOI_TEMPLATE)

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"
}

我的映射(TMPOI_MAPPING)

My Mappings (TMPOI_MAPPING)

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

我的索引填充方法

索引是通过另一个称为 createIndex()的方法创建的。它的工作正常。但是当我尝试通过以下代码填充索引时,我会得到 ERROR

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();
}   

错误


MapperParsingException [解析失败];嵌套:IllegalStateException [混合字段类型:类org.elasticsearch.index.mapper.core.StringFieldMapper $ StringFieldType!=类字段_id上的类org.elasticsearch.index.mapper.internal.IdFieldMapper $ IdFieldType;

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是保留字段。尝试从TMPOI_TEMPLATE中删除以下行( _id: f212949c-7b67-45db-9f76-fe18bf951722),然后找到另一种传递文档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.

这篇关于IllegalStateException用于混淆字段类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆