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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With