Perl and new Boolean restriction in ES5

(Ron Kass) #1

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?

(David Pilato) #2

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

(Ron Kass) #3

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?)

(David Pilato) #4

I see. @Clinton_Gormley might have an idea.

(JΓΆrg Prante) #5

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

(Ron Kass) #6

same result. not a Boolean.

(Clinton Gormley) #7

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

  "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.

(system) #8

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