Perl and new Boolean restriction in ES5

In ElasticSearch 5, we now get the following error message
[DEPRECATION] 299 Elasticsearch-5.4.0-780f8c4 "Expected a boolean [true/false] for property [isAnonymous] but got [0]"
(isAnonymous is just a field name we use)

However, there is no such thing as a boolean in perl.
Until now we passed 0/1, for those.. which worked fine. But.. now, since the shift to 5, we get this message, which probably means bad news.

What do we do?
:sweat:

Change it in your application before switching to 6.0.
Or use an ingest pipeline (but slower)

Change what in the application?

Note: There is no Boolean in perl. so basically ES is expecting something that doesn't exist in the language it officially supports.
(am I missing something?)

I see. @Clinton_Gormley might have an idea.

What happens if you use strings in Perl, i.e. 'true'/'false' ?

same result. not a Boolean.

You can use the "true" / "false" strings - it works just fine, and I don't get any deprecation warnings using them:

PUT t
{
  "mappings": {
    "t": {
      "properties": {
        "foo": {
          "type": "boolean"
        }
      }
    }
  }
}

PUT t/t/1
{
  "foo": "true"
}

That said, the various JSON encoders in Perl provide objects which represent Booleans - the names differ depending on the encoder you use. When decoding JSON, they'll return an object like JSON::PP::Boolean which work as true & false. When encoding JSON, you can represent true as \1 and false as \0. You can also use JSON::true, JSON::false from the JSON module, or Types::Serializer::true and Types::Serializer::false from Types::Serializer, which is used by JSON::XS.

It doesn't matter which one you use - these modules interact just fine.

1 Like

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