28

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.

RamRajVasavi
  • 896
  • 4
  • 12
  • 28

2 Answers2

32

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

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.

1st Document

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

2nd Document

{
    "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 causes the problem. Don't try to index different type of values in a single field in different documents.

slm
  • 15,396
  • 12
  • 109
  • 124
Arun Prakash
  • 1,717
  • 17
  • 26
  • Yes, looks like you can't store different value types in a single field. Same thing mentioned here: http://blog.endpoint.com/2013/04/elasticsearch-object-mapping-eof-400.html – n0rm1e Jul 23 '15 at 01:20
0

I had same issue, first I have indexed a document with one filed of type List and it was working, then I changed the value from simple String to an Object(user defined model, eg: Employee, which converted to Json String), then I was getting the above issue.

Updated the previous documents and mappings, then it started working

Yoga Gowda
  • 357
  • 4
  • 8