Current token (START_OBJECT) not of boolean type


I'm getting this error:

ERROR 2018/12/28 09:47:00 Bulk response item: {"_index":"events","_type":"_doc","_id":"5bff91647395d80013fa5f8e","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse [data.coupon_applied]","caused_by":{"reason":"Current token (START_OBJECT) not of boolean type\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@79f245e6; line: 1, column: 133]","type":"json_parse_exception"}}}

The problem is, data.coupon_applied has boolean and json values in our MongoDB database. How can I modify the type in elasticsearch so it can accept both values?

Or should I change the data model in MongoDB?


If you don't need search the content of data.coupon_applied you can map it as a disabled object:

"coupon_applied": {
     "type": "object",
     "enabled": false

If you need to index the content, you have to either convert false to null or to {} this can be done in your application when you extract data from MongoDB, using ingest node or by changing the data model in MongoDB.

Thanks @Igor_Motov

Can I update the mapping without removing the index?

You can only add new fields to the index, but it is not possible to change a field type or delete a field.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.