Enable _size in index template

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:

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:

"_size": {
  "enabled": true
}

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

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?

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

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

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

{
"_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
    },
...

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

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

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

This is an issue IMO. Could you open an issue in GitHub - elastic/kibana: Your window into the Elastic Stack?

Note that you can create the template manually though:

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

As the bug is "only" in the UI.

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

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