# Must\_exist

**URL:** <https://discuss.elastic.co/t/must-exist/249009>\
**Category:** Elasticsearch\
**Created:** [September 17, 2020, 4:23pm UTC](https://discuss.elastic.co/t/must-exist/249009 "2020-09-17T16:23:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rihad](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@rihad](https://discuss.elastic.co/u/rihad)\
**Post date:** [September 17, 2020, 4:23pm UTC](https://discuss.elastic.co/t/must-exist/249009/1 "2020-09-17T16:23:35Z")

</div>

Hi there! How do I use the must\_exist alias attribute that appeared in version 7.9?

> **[Update index alias API | Elasticsearch Reference \[7.9\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-aliases.html)**

This is what I try:

```auto
curl -sS -X POST http://localhost:9200/_aliases?timeout=15m&master_timeout=15m -H Content-Type: application/json -d'
    {
      "actions" : [
        { "remove": { "index" : "foo", "alias" : "bar", "must_exist": true } },
        { "add": { "index" : "foo", "alias" : "baz" } }
      ]
    }'

```

And the result:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "x_content_parse_exception",
        "reason": "[4:131] [remove] unknown field [must_exist]"
      }
    ],
    "type": "x_content_parse_exception",
    "reason": "[4:145] [aliases] failed to parse field [actions]",
    "caused_by": {
      "type": "x_content_parse_exception",
      "reason": "[4:145] [alias_action] failed to parse field [remove]",
      "caused_by": {
        "type": "x_content_parse_exception",
        "reason": "[4:131] [remove] unknown field [must_exist]"
      }
    }
  },
  "status": 400
}

```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [September 18, 2020, 2:26pm UTC](https://discuss.elastic.co/t/must-exist/249009/2 "2020-09-18T14:26:00Z")

</div>

@rihad were you able to figure this out?

I can't find anything on this and it appears everything is correct.

The only thing I can think is to ensure you are on 7.9 since it only exists in that version. But since you specifically mentioned that I am guessing you are.

---

<div class="post-metadata">

**Author:** ![rihad](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@rihad](https://discuss.elastic.co/u/rihad)\
**Post date:** [September 18, 2020, 2:35pm UTC](https://discuss.elastic.co/t/must-exist/249009/3 "2020-09-18T14:35:20Z")

</div>

I have no idea. Please note that attempting to use must\_exist for "add" results in this error:

`"[must_exist] is unsupported for [ADD]"`

And mistyping the action like "ustexist": true, also for the "add" command, results in:

`"[1:66] [add] unknown field [ustexist] did you mean [must_exist]?"`

which suggests that this version (7.9.1) knows what must\_exist is.

Both of these used for the "remove" command result in "unknown field XXX"

---

<div class="post-metadata">

**Author:** ![rihad](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@rihad](https://discuss.elastic.co/u/rihad)\
**Post date:** [September 18, 2020, 3:12pm UTC](https://discuss.elastic.co/t/must-exist/249009/4 "2020-09-18T15:12:48Z")

</div>

I might be terribly wrong, but is it ok that must\_exist is defined for the ADD parser (and not REMOVE)?

> <https://github.com/elastic/elasticsearch/blob/36bc6f738078e9fe23fc4e7bf7a433462b2fedac/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java#L199>

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [September 18, 2020, 3:18pm UTC](https://discuss.elastic.co/t/must-exist/249009/5 "2020-09-18T15:18:04Z")

</div>

@rihad I tested and getting the same results as you. Taking a deeper look into, thanks.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [September 18, 2020, 4:26pm UTC](https://discuss.elastic.co/t/must-exist/249009/6 "2020-09-18T16:26:05Z")

</div>

@rihad I ran out of ideas so I opened up an [issue on github](https://github.com/elastic/elasticsearch/issues/62642) if you want to follow that also. Thank you.

---

<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:** [October 16, 2020, 4:26pm UTC](https://discuss.elastic.co/t/must-exist/249009/7 "2020-10-16T16:26:18Z")

</div>

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