# Sending Integer or Byte from Cloud Code

**URL:** <https://community.parseplatform.org/t/sending-integer-or-byte-from-cloud-code/1587>\
**Category:** Cloud Code\
**Created:** [April 19, 2021, 7:49am UTC](https://community.parseplatform.org/t/sending-integer-or-byte-from-cloud-code/1587 "2021-04-19T07:49:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lsmilek1](https://community.parseplatform.org/user_avatar/community.parseplatform.org/lsmilek1/32/629_2.png) [@lsmilek1](https://community.parseplatform.org/u/lsmilek1)\
**Post date:** [April 19, 2021, 7:49am UTC](https://community.parseplatform.org/t/sending-integer-or-byte-from-cloud-code/1587/1 "2021-04-19T07:49:02Z")

</div>

Hello,

i am investigating the integration of ElasticSearch and am following the documentation and the example of explicit mapping. I created index, where I want to map fields as smallest Integer - the value will be always in range 0…100 - because the documentation claims that this would be beneficial in performance. Lets throw an example:

```auto
PUT /profile/
{
  "mappings": {
    "properties": {
      "ag": { "type": "byte" },
      "gn": { "type": "byte" },
      "d": { "type": "boolean" }
    }
  }
}

```

But then when I use this JavaScript client in the Cloud Code and want to pass values that are as Number I get an error. Example:

```auto
async function(profile, newDocument) { //PrsProfile, Bool
    const result = await esClient.index({
        id: profile.id,
        index: 'profile',
        type: ((newDocument == true) ? 'create' : 'index'),
        body: {
            ag: profile.get("ag"), // <-- this is Number of value 36, but elastic expects byte type
            gn: profile.get("gn"), // <-- this is Number of value 0, but elastic expects byte type
            d: profile.get("d")
        }
    })

    return (`Hello world + ${result}`);

```

Error: **mapping update rejected by primary  
java.lang.IllegalArgumentException: mapper [ag] cannot be changed from type [byte] to [long]**

using dynamic mapping is working fine, because it maps as **long**

Am I correct that it is not possible to use Cloud Code function and pass “byte” or “integer” type in that body header? Or is there a way how to pass Integer?

Trying it through Int8Array this way also don’t work:

```
    var ageIntArr = new Int8Array(1);
    ageIntArr[0] = 30;
    const result = await esClient.index({        
        id: profile.id,
        index: 'profile',
        type: ((newDocument == true) ? 'create' : 'index'),
        body: {
            ag: ageIntArr[0]
        }
    })

```

Thank you!

---

<div class="post-metadata">

**Author:** ![lsmilek1](https://community.parseplatform.org/user_avatar/community.parseplatform.org/lsmilek1/32/629_2.png) [@lsmilek1](https://community.parseplatform.org/u/lsmilek1)\
**Post date:** [April 19, 2021, 1:15pm UTC](https://community.parseplatform.org/t/sending-integer-or-byte-from-cloud-code/1587/2 "2021-04-19T13:15:07Z")

</div>

The issue was a **type** instead of **op\_type** in the index function
