Reindex from 2.4 to 6.5 failed on boolean type

In 2.4, a Boolean type supports 0|1|true|false,
but seems 6.5 does not support 0|1 any more.

So my reindex failed with error "failed to parse field [claimed] of type [boolean]"

reason":"Current token (VALUE_NUMBER_INT) not of boolean type\n at [Source: org.elasticsearch.common.bytes.BytesReference

Any way to get around this?

Yes, that bit me too. Before Elasticsearch 6.0 you could use 1 and 0 for boolean true and false, but not anymore.

You will have to update the integer values to booleans, 0 -> false and 1 -> true, before you can upgrade to Elasticsearch 6.x.

The way I solved it was to create a pipeline with a processor that transformed the problematic integer values to proper booleans and then used this pipeline in a reindex operation. When all indices had been reindexed I could upgrade my cluster to ES 6 without further problems.

Both pipelines and the reindex API are available in Elasticsearch 2.4 but I have no experience using them in that old version; my upgrade was done from version 5.6 so if you struggle using pipelines in the reindexing step you could first try to upgrade from 2.4 to 5.6, without changing the boolean field values, and from there to 6.5 using the aforementioned pipeline to fix the integer values.


Got another nasty way to get around this issue with the script:

"source": "boolean clean = ctx._source["user"].get("clean") instanceof boolean ? ctx._source["user"].get("clean") : ctx._source["user"].get("clean") instanceof Integer ? ("1" == ctx._source["user"].get("clean").toString()) : false;

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