# Enable \_size in index template

**URL:** https://discuss.elastic.co/t/enable-size-in-index-template/278055
**Category:** Elasticsearch
**Created:** [July 7, 2021, 10:12am UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055 "2021-07-07T10:12:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![radovan](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@radovan](https://discuss.elastic.co/u/radovan)
#### Post date: [July 7, 2021, 10:12am UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/1 "2021-07-07T10:12:00Z")

</div>

Hi,  
I've installed mapper size plugin on all of our elastic nodes, I can see/use the size field, when I enable it on an index:

```auto
PUT index-xxx/_mapping
{
  "_size": {
    "enabled": true
  }
}

```

and create a scripted field, but how to enable \_size for good? Because of ILM policy, every new index has \_size not enabled. I tried copying existing options in JSON and putting there:

```auto
"_size": {
  "enabled": true
}

```

while editing index template and trying to Load JSON, but it says:

```auto
1 invalid option detected in mappings object

If you continue loading the object, only valid options will be accepted.

```

So what's the proper way to enable \_size for indices with ILM policy?

---

<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 7, 2021, 10:36am UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/2 "2021-07-07T10:36:05Z")

</div>

Could you share the full request you are running to create/update the index template?

---

<div class="post-metadata">

### Author: ![radovan](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@radovan](https://discuss.elastic.co/u/radovan)
#### Post date: [July 7, 2021, 10:57am UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/3 "2021-07-07T10:57:23Z")

</div>

Well it's not a request, I used Kibana (Index Management) to Load JSON.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/b/ebc6df3dc78312cffaad8dcada254387248673b9.png)

Just copied original mapping from index template, pasted there and added \_size mapping like this:

```auto
{
"_doc": {
    "_routing": {
      "required": false
    },
    "numeric_detection": false,
    "_meta": {
      "beat": "auditbeat",
      "version": "7.11.0"
    },
    "runtime": {
      "size": {
        "type": "long",
        "script": {
          "source": "emit(doc['_size'])"
        }
      }
    },
    "_source": {
      "excludes": [],
      "includes": [],
      "enabled": true
    },
    "dynamic": true,
    "_size": {
      "enabled": true
    },
...

```

---

<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 7, 2021, 11:53am UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/4 "2021-07-07T11:53:31Z")

</div>

IIRC you can see what the request will look like. Could you share that?

---

<div class="post-metadata">

### Author: ![radovan](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@radovan](https://discuss.elastic.co/u/radovan)
#### Post date: [July 7, 2021, 12:41pm UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/5 "2021-07-07T12:41:46Z")

</div>

Well you can't see that. You just paste your mapping JSON here and then (after clicking on Load and overwrite) the error message I posted above shows up

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/b/1bcd5e0e9b7177609974695acf9dd109816c1dd4.png)

---

<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 7, 2021, 3:11pm UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/6 "2021-07-07T15:11:05Z")

</div>

I see. `enabled` is not supported and at the end, it generates:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/1/41fcd46cb69829addf61cb381d2c215f9bdb88a0.png)

This is an issue IMO. Could you open an issue in [GitHub - elastic/kibana: Your window into the Elastic Stack](https://github.com/elastic/kibana)?

---

<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 7, 2021, 3:19pm UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/7 "2021-07-07T15:19:53Z")

</div>

Note that you can create the template manually though:

```auto
PUT /_index_template/mytemplate
{
  "index_patterns": [
    "te*",
    "bar*"
  ],
  "template": {
    "mappings": {
      "_size": {
        "enabled": true
      }
    }
  }
}

```

As the bug is "only" in the UI.

---

<div class="post-metadata">

### Author: ![radovan](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@radovan](https://discuss.elastic.co/u/radovan)
#### Post date: [July 7, 2021, 3:25pm UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/8 "2021-07-07T15:25:28Z")

</div>

Sure, will open an issue there. And thanks for the idea, I didn't try to create it through API.

---

<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 4, 2021, 3:25pm UTC](https://discuss.elastic.co/t/enable-size-in-index-template/278055/9 "2021-08-04T15:25:41Z")

</div>

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