gpt4 book ai didi

elasticsearch - 如何解决 MapperParsingException : object mapping for [test] tried to parse as object, 但得到 EOF

转载 作者:行者123 更新时间:2023-11-29 02:43:29 25 4
gpt4 key购买 nike

在 ElasicSearch 中,我创建了一个索引“测试”和如下所示的映射

{
"index": {
"_index": "test",
"_type": "test"
},
"settings": {
"index.number_of_replicas": 0,
"index.number_of_shards": 2
},
"mappings": {
"_default_": {
"date_detection": false
},
"test": {
"properties": {
"dateModified": {
"dynamic": "true",
"properties": {
"date": {
"type": "string"
},
"time": {
"type": "string"
}
}
}
}
}
}
}

索引创建成功。我给了日期

{"index":{"_index":"test","_type":"test"}}
{"dateModified":{"date":"25/05/2015","time":"17:54 IST"}}

记录插入成功。如果我给出如下所示的数据,它会出错

{"index":{"_index":"test","_type":"test"}}
{"dateModified":"25/05/2015"}

org.elasticsearch.index.mapper.MapperParsingException: object mapping for [test] tried to parse as object, but got EOF, has a concrete value been provided to it?
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:498)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:541)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:490)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:392)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:193)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:511)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:419)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

那么如何解决这个问题,我看了一些与这个问题相关的博客和帖子,但他们没有给出解决这个问题的方法。

最佳答案

要解决这个问题,您需要在字段dateModified 中索引相同类型的值。听起来您在一个文档中索引了一个内部元素,在下一个文档中索引了字符串值。

dateModified 字段的映射是一种内部对象,它有 2 个字段,datetime .该映射也是动态,它是在您为第一个文档编制索引时创建的。

第一份文件

{
"dateModified": {
"date": "25/05/2015",
"time": "17:54 IST"
}
}

第二份文件

{
"dateModified": "25/05/2015"
}

它清楚地表明您正在尝试为特定字段的具有不同类型值的文档编制索引。 Elasticsearch 不支持。每个字段都应具有唯一的数据类型,并且值也应与映射中定义的相同。

这会导致问题。不要尝试在不同文档的单个字段中索引不同类型的值。

关于elasticsearch - 如何解决 MapperParsingException : object mapping for [test] tried to parse as object, 但得到 EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30454108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com