# Perl and new Boolean restriction in ES5

**URL:** <https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529>\
**Category:** Elasticsearch\
**Created:** [July 25, 2017, 6:42pm UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529 "2017-07-25T18:42:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron\_Kass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ron_kass/32/20427_2.png) [@Ron\_Kass](https://discuss.elastic.co/u/Ron_Kass)\
**Post date:** [July 25, 2017, 6:42pm UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/1 "2017-07-25T18:42:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 25, 2017, 7:08pm UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/2 "2017-07-25T19:08:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ron\_Kass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ron_kass/32/20427_2.png) [@Ron\_Kass](https://discuss.elastic.co/u/Ron_Kass)\
**Post date:** [July 25, 2017, 7:13pm UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/3 "2017-07-25T19:13:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 25, 2017, 7:47pm UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/4 "2017-07-25T19:47:57Z")

</div>

I see. @Clinton_Gormley might have an idea.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 25, 2017, 11:01pm UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/5 "2017-07-25T23:01:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ron\_Kass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ron_kass/32/20427_2.png) [@Ron\_Kass](https://discuss.elastic.co/u/Ron_Kass)\
**Post date:** [July 25, 2017, 11:12pm UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/6 "2017-07-25T23:12:53Z")

</div>

same result. not a Boolean.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 26, 2017, 8:12am UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/7 "2017-07-26T08:12:00Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 23, 2017, 8:12am UTC](https://discuss.elastic.co/t/perl-and-new-boolean-restriction-in-es5/94529/8 "2017-08-23T08:12:11Z")

</div>

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