【问题标题】:IllegalStateException for mixing up field types混合字段类型的 IllegalStateException
【发布时间】:2016-12-15 20:29:59
【问题描述】:

我的 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)

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

我填写索引的方法

索引是由另一个名为 createIndex() 的方法创建的。它工作正常。但是当我尝试通过以下代码填充索引时,我会得到 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];

【问题讨论】:

    标签: elasticsearch elasticsearch-2.0


    【解决方案1】:

    _id 是保留字段。尝试从 TMPOI_TEMPLATE 中删除以下行 ("_id": "f212949c-7b67-45db-9f76-fe18bf951722") 并找到另一种传递文档 ID 的方法。 希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      您需要从文档本身中删除 _id

      【讨论】:

        猜你喜欢
        • 2016-07-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-18
        • 1970-01-01
        • 2015-11-04
        • 2014-01-10
        • 2021-12-15
        相关资源
        最近更新 更多