首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elasticsearch MapperParsingException

Elasticsearch MapperParsingException
EN

Stack Overflow用户
提问于 2015-10-12 21:18:56
回答 2查看 1.5K关注 0票数 0

我正在尝试将以下数据索引到elasticsearch,

代码语言:javascript
复制
{
"_id": "5619578c1983757a72efef15",
"aseg": {},
"cs": {
    "source": "None",
    "ss": "In Transit",
    "sr": "Weight Captured",
    "act": "+B",
    "pid": "BAG21678106",
    "st": "UD",
    "dest": "Bharatpur_DC (Rajasthan)",
    "u": "J",
    "sl": "Jaipur_Hub (Rajasthan)",
    "ud": "2015-10-12T14:59:44.270000",
    "sd": "2015-10-12T14:59:44.270000"
},

"nsl": [
    {
        "dt": [
            2015,
            10,
            10
        ],
        "code": "X-PPONM"
    },
    {
        "dt": [
            2015,
            10,
            11
        ],
        "code": "X-UCI"
    },
]
}

但作为回报,我得到了这个错误

代码语言:javascript
复制
MapperParsingException[failed to parse [cs.nsl]]; nested: ElasticsearchIllegalArgumentException[unknown property [dt]];

我检查了映射,映射是正确的,嵌套在cs dict中的nsl在根级别的映射与nsl不同。

代码语言:javascript
复制
            "cs": {
            "properties": {
                "act": {
                    "type": "string"
                },
                "add": {
                    "type": "string"
                },
                "asr": {
                    "type": "string"
                },
                "bucket": {
                    "type": "string"
                },
                "dest": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "dwbn": {
                    "type": "string"
                },
                "lcld": {
                    "type": "string"
                },
                "lat": {
                    "type": "string"
                },
                "lon": {
                    "type": "string"
                },
                "loc": {
                    "type": "double"
                },
                "nsl": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "ntd": {
                    "type": "date",
                    "format": "dateOptionalTime"
                },
                "pbs": {
                    "type": "string"
                },
                "pid": {
                    "type": "string"
                },
                "pupid": {
                    "type": "string"
                },
                "sd": {
                    "type": "date",
                    "format": "dateOptionalTime"
                },
                "sl": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "source": {
                    "properties": {
                        "source": {
                            "type": "string"
                        },
                        "source_id": {
                            "type": "string"
                        },
                        "source_type": {
                            "type": "string"
                        }
                    }
                },
                "sr": {
                    "type": "string"
                },
                "ss": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "st": {
                    "type": "string"
                },
                "u": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "ud": {
                    "type": "date",
                    "format": "dateOptionalTime"
                },
                "vh": {
                    "type": "string"
                }
            }
        },

对于根级别的nsl映射如下

代码语言:javascript
复制
        "nsl": {
            "properties" : {
                "code" : {
                        "type" : "string",
                        "index": "not_analyzed"
                    },
                "dt" : {
                    "type" : "string",
                    "index": "not_analyzed"
                }
            }
        },

这只发生在少数几条记录上,其余的都同步得很好。有效负载没有任何变化。此外,nsl是cs中的稀疏密钥。

EN

回答 2

Stack Overflow用户

发布于 2015-10-12 21:24:21

在您的映射中,nsl如下-

代码语言:javascript
复制
            "nsl": {
                "type": "string",
                "index": "not_analyzed"
            },

根据映射,Elasticsearch期望nsl字段有一个具体的字符串值,但它是您提供的文档中的一个对象数组。Elasticsearch一旦它有了映射,它就是确定的。不能将对象数据插入到字符串字段中。

票数 2
EN

Stack Overflow用户

发布于 2016-06-09 13:33:18

我在没有预先设置任何映射的情况下尝试您的文档,如下所示:

代码语言:javascript
复制
{
    "aseg": {},
    "cs": {
        "source": "None",
        "ss": "In Transit",
        "sr": "Weight Captured",
        "act": "+B",
        "pid": "BAG21678106",
        "st": "UD",
        "dest": "Bharatpur_DC (Rajasthan)",
        "u": "J",
        "nsl":"foo",
        "sl": "Jaipur_Hub (Rajasthan)",
        "ud": "2015-10-12T14:59:44.270000",
        "sd": "2015-10-12T14:59:44.270000"
    },
    "nsl": [
        {
            "dt": [
                2015,
                10,
                10
            ],
            "code": "X-PPONM"
        },
        {
            "dt": [
                2015,
                10,
                11
            ],
            "code": "X-UCI"
        }
    ]
}

ES创建的映射如下:

代码语言:javascript
复制
"nsl": {
    "properties": {
        "dt": {
            "type": "long"
        },
        "code": {
            "type": "string"
        }
     }
 }

如您所见,ES将"dt“类型设置为"long”,这是日期类型的内部表示形式。因此,可能需要更改类型?

此外,如果没有看到成功的文档,很难猜测,但我相信这些文档没有"dt“字段值。

当然,您可以随意在任何字段中使用"not_analyzed“。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33082199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档