Must_exist

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

This is what I try:

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:

{
  "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
}

@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.

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"

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

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

@rihad I ran out of ideas so I opened up an issue on github if you want to follow that also. Thank you.

1 Like

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