如何解决MapperParsingException:[test]的对象映射试图解析为对象,但是获得了EOF [英] How to solve MapperParsingException: object mapping for [test] tried to parse as object, but got EOF

查看:1583
本文介绍了如何解决MapperParsingException:[test]的对象映射试图解析为对象,但是获得了EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ElasicSearch中,我创建了一个索引test和下面的映射

In ElasicSearch i created one index "test" and mappings like below

{
  "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 is created successfully. I given date like

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

成功插入记录如果我给下面的数据给出错误

Record inserted succesfully.If i give data like below it giving error

{"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)

然后如何解决这个问题,我读了一些与这个问题有关的博客和帖子,但是他们没有解决这个问题。

Then how to solve this problem,I read some blog and posts related to this issue but they don't given solution to this problem.

推荐答案

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

To solve this issue, you need to index a same type of value in the field dateModified. it sounds you index a inner element in one document and the string value in the next document.

dateModified的映射字段是一种内部对象,它有2个字段, date & 时间

The mapping for dateModified field is kind of a inner object which has 2 fields, date & time. The mapping also dynamic which has created while you index the first document.

第一个文件 >

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

第二个文件

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

它清楚地表示您正在尝试用不同的索引特定字段的值类型。弹性搜索不支持。每个字段都应该具有唯一的数据类型,并且值也应与映射中定义的相同。

It clearly says that you are trying to index a document with different type of values for a particular field. which is not supported by elastic search. each and every field should have a unique data type and the values also should be same as defined in the mapping.

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

This cause the problem. Don't try to index different type of values in a single field in different document.

这篇关于如何解决MapperParsingException:[test]的对象映射试图解析为对象,但是获得了EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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