# Custom plug-in how to implement Map and Set types of Settings

**URL:** <https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719>\
**Category:** Elasticsearch\
**Created:** [July 4, 2021, 3:34am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719 "2021-07-04T03:34:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![asasas234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asasas234/32/113152_2.png) [@asasas234](https://discuss.elastic.co/u/asasas234)\
**Post date:** [July 4, 2021, 3:34am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/1 "2021-07-04T03:34:19Z")

</div>

I want to develop a plugin that needs to use the Settings API to save some state across the cluster, these states are of Set type and Map type, but I can't find the relevant API to set, can anyone help me to see how to do it?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 6, 2021, 1:30am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/2 "2021-07-06T01:30:14Z")

</div>

Can you elaborate more on what you are trying to do here?  
What do you mean by "Set" and "Map" type exactly.

---

<div class="post-metadata">

**Author:** ![asasas234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asasas234/32/113152_2.png) [@asasas234](https://discuss.elastic.co/u/asasas234)\
**Post date:** [July 6, 2021, 2:27am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/3 "2021-07-06T02:27:55Z")

</div>

I want to use the plug-in’s org.elasticsearch.common.settings.Setting API to set and store Java’s java.util.Set and Java.util.Map type objects, but I don’t know how to do it. I found that there are only java.util.List type objects.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [July 6, 2021, 3:21am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/4 "2021-07-06T03:21:13Z")

</div>

The settings API reads from the `elasticsearch.yml` file (and/or from dynamic cluster settings).

If is easier if you start with how you want these settings to look in the Yaml, and then work out how to parse them, rather than starting with the settings API.

Provide us with an example of how these new settings would look in `elasticsearch.yml` and we can give you some tips on how to parse them.

---

<div class="post-metadata">

**Author:** ![asasas234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asasas234/32/113152_2.png) [@asasas234](https://discuss.elastic.co/u/asasas234)\
**Post date:** [July 6, 2021, 4:46am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/5 "2021-07-06T04:46:22Z")

</div>

Maybe I didn't express myself clearly, I want to customize the plugin to store some state data through the settings api, which may be of type Set or Map\<String,Vo\>, and Vo is my custom value object

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [July 6, 2021, 5:45am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/6 "2021-07-06T05:45:36Z")

</div>

The Settings API provides a mechanism to configure your plugin. It isn't the right way to store state for your plugin.

It sounds like you want to store data in cluster state or in a system index.

Cluster state is only suitable if it's a small amount of data and you are very careful about compatibility between versions - a broken cluster state can make your cluster unstable, or potentially unrecoverable.

---

<div class="post-metadata">

**Author:** ![asasas234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asasas234/32/113152_2.png) [@asasas234](https://discuss.elastic.co/u/asasas234)\
**Post date:** [July 6, 2021, 6:12am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/7 "2021-07-06T06:12:54Z")

</div>

> [@TimV](#):
>
> Cluster state is only suitable if it's a small amount of data and you are very careful about compatibility between versions - a broken cluster state can make your cluster unstable, or potentially unrecoverable.

Is there a better way than the Settings API? Storing data in a specialized index? How do I call the API to do this? Do you have an example?

---

<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 3, 2021, 6:13am UTC](https://discuss.elastic.co/t/custom-plug-in-how-to-implement-map-and-set-types-of-settings/277719/8 "2021-08-03T06:13:32Z")

</div>

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