# How to enable size-mapper plugin / \_size field via RestHighLevelClient

**URL:** https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [September 15, 2022, 11:16am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501 "2022-09-15T11:16:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [September 15, 2022, 11:16am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/1 "2022-09-15T11:16:46Z")

</div>

Hey Folks,

I'm trying to add the \_size field to an existing index via RestHighLevelClient

> **[Using the \_size field | Elasticsearch Plugins and Integrations \[8.4\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-size-usage.html)**

and failing to see there I could put the following

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

```

the Dev Tools equivalent is

```auto
curl -X PUT "localhost:9200/my-index-000001?pretty" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "_size": {
      "enabled": true
    }
  }
}
'

```

trying the same for an existing index:

```auto

PUT existing/_mapping
{
  "mappings": {
    "_size": {
      "enabled": true
    }
  }
}

```

will result in

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters: [mappings : {_size={enabled=true}}]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [mappings : {_size={enabled=true}}]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "Root mapping definition has unsupported parameters: [mappings : {_size={enabled=true}}]"
    }
  },
  "status" : 400
}

```

---

<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: [September 15, 2022, 2:43pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/2 "2022-09-15T14:43:24Z")

</div>

Did you install the plugin on all nodes and restarted the cluster?

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [September 20, 2022, 12:42pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/3 "2022-09-20T12:42:13Z")

</div>

Yes I did and it works when doing it via the Devtools console.  
I just don't know

- How to do it for an existing index
- How to translate it to a mappings.json to do it programmatically via

```nohighlight
private val elasticsearchClient: org.elasticsearch.client.RestHighLevelClient
elasticsearchClient.indices().putIndexTemplate(
            PutComposableIndexTemplateRequest()
                .name(elkConfig.templateName)
                .indexTemplate(indexTemplate),
            RequestOptions.DEFAULT
        )

```

which consumes a `mapping.json` which works for normal index templates but I'm unable to add the "\_size" field:

```auto
{
  "mappings": {
    "_doc": {
      "_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: [September 27, 2022, 3:25am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/4 "2022-09-27T03:25:10Z")

</div>

Could you try with:

```auto
PUT existing/_mapping
{
  "_size": {
    "enabled": true
  }
}

```

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 4, 2022, 11:42am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/5 "2022-10-04T11:42:39Z")

</div>

> [@dadoonet](#):
>
> ```auto
> PUT existing/_mapping
> {
> "_size": {
> "enabled": true
> }
> }
> 
> ```

@dadoonet I noticed the plugin wasn't activated on our cluster. Also a restart of all nodes didn't work

---

<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: [October 4, 2022, 1:01pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/6 "2022-10-04T13:01:20Z")

</div>

So the plugin has been deployed on the cluster now?

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 4, 2022, 1:23pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/7 "2022-10-04T13:23:00Z")

</div>

hard to tell  
the following request fails:

```auto
PUT test_size_plugin
{
  "mappings": {
    "_size": {
      "enabled": true
    }
  }
}

```

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters: [_size : {enabled=true}]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [_size : {enabled=true}]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "Root mapping definition has unsupported parameters: [_size : {enabled=true}]"
    }
  },
  "status" : 400
}

```

`GET /_cat/plugins?v=true&s=component&h=name,component,version,description`

While looking through the JSON, I noticed that the plugin seems to be activated on the “resources” level, but not on the “cluster\_topology” level.

`$.resources.elasticsearch.plan.elasticsearch.enabled_built_in_plugins = [“mapper-size”]`

The plugin shows up in the plan definition of elasticsearch but not in the node definition:

```auto
  "resources": {
    "elasticsearch": [
      {
        "region": "aws-eu-central-1",
        "ref_id": "main-elasticsearch",
        "plan": {
          "cluster_topology": [
            {
              "zone_count": 2,
              "elasticsearch": {
                "user_plugins": [],
                "system_settings": {
                     ...
                },
                "user_bundles": [],
                "enabled_built_in_plugins": [] # <- The plugin seems to be missing here and in the other nodes
              },
... 

```

---

<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: [October 4, 2022, 1:57pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/8 "2022-10-04T13:57:55Z")

</div>

So it has not been deployed. You need to add the plugin to all nodes and restart all nodes first.

Until `GET /_cat/plugins?v` shows it, you won't be able to use the plugin.

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 4, 2022, 2:27pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/9 "2022-10-04T14:27:52Z")

</div>

We did that, even tried twice

---

<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: [October 4, 2022, 3:18pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/10 "2022-10-04T15:18:02Z")

</div>

But what did you do exactly? I'm lost 🙂

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 4, 2022, 4:16pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/11 "2022-10-04T16:16:10Z")

</div>

Oh sorry:

- enable the size mapper plugin in the deployment of our [elastic.co](http://elastic.co) instance
- restart the whole deployment
- try to query enabled plugins =\> it’s missing
- try to enabled the mapping for “\_size” fields =\> fails

We tried the steps twice (with additional restart after disabling the plug-in before adding again)

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [October 4, 2022, 4:18pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/12 "2022-10-04T16:18:27Z")

</div>

@dadoonet Is this a setting you can add to an existing index holding data?

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 4, 2022, 4:34pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/13 "2022-10-04T16:34:53Z")

</div>

@Christian_Dahlqvist it fails for new and existing Index with data

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [October 4, 2022, 4:51pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/14 "2022-10-04T16:51:41Z")

</div>

What is the output of the [cat plugins API](https://www.elastic.co/guide/en/elasticsearch/reference/8.4/cat-plugins.html)?

Are you able to set it in an index template and create a new index based on that?

---

<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: [October 5, 2022, 6:13am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/15 "2022-10-05T06:13:24Z")

</div>

I'm not sure you can but first I want to make sure the plugin is working. 😊

---

<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: [October 5, 2022, 6:14am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/16 "2022-10-05T06:14:51Z")

</div>

You are running on [cloud.elastic.co](http://cloud.elastic.co)? Is that correct?

If so, did you save the settings when you added the plugin? I have been confused myself in the past by the UI.

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 5, 2022, 6:54am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/17 "2022-10-05T06:54:21Z")

</div>

Yes 👍🏼  
The plug-in activation is also visible the the deployment activity summary.

However it seems like the plug-in is not activated on all nodes, see the snippet of “Equivalent API JSON” which represents enabling the feature via UI

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 5, 2022, 6:56am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/18 "2022-10-05T06:56:52Z")

</div>

It’s missing in the cat output as well

---

<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: [October 5, 2022, 9:52am UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/19 "2022-10-05T09:52:22Z")

</div>

So I'd suggest to open a ticket with the support team.

---

<div class="post-metadata">

### Author: ![rowi1de](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rowi1de/32/110925_2.png) [@rowi1de](https://discuss.elastic.co/u/rowi1de)
#### Post date: [October 18, 2022, 7:19pm UTC](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501/20 "2022-10-18T19:19:38Z")

</div>

Yes did that … research is ongoing

[Next page](https://discuss.elastic.co/t/how-to-enable-size-mapper-plugin-size-field-via-resthighlevelclient/314501.md?page=2)
