Documentation Error RE: elasticsearch multi-target syntax

In the API Conventions Documentation, you state:

Aliases are resolved after wildcard expressions. This can result in a request that targets an excluded alias. For example, if test3 is an index alias, the pattern test*,-test3 still targets the indices for test3. To avoid this, exclude the concrete indices for the alias instead.

However, my own testing has revealed that the opposite is true.

If I include by alias, and exclude by concrete name, I end up with the index that I explicitly attempted to exclude. However, if I include by alias and exclude by alias, it correctly excludes the desired index.

$ curl -XPUT 'localhost:19191/my-idx-aaa-2022-09-16-rw' -H 'Content-Type: application/json' -d '{"aliases": { "my-idx-aaa-2022-09-16": {} } }'
{"acknowledged":true,"shards_acknowledged":true,"index":"my-idx-aaa-2022-09-16-rw"}

$ curl -XPUT 'localhost:19191/my-idx-bbb-2022-09-16-rw' -H 'Content-Type: application/json' -d '{"aliases": { "my-idx-bbb-2022-09-16": {} } }'
{"acknowledged":true,"shards_acknowledged":true,"index":"my-idx-bbb-2022-09-16-rw"}

$ curl -s 'localhost:19191/my-idx-*-2022-09-16,-my-idx-aaa-2022-09-16/_settings?pretty' | jq keys
[
  "my-idx-bbb-2022-09-16-rw"
]

$ curl -s 'localhost:19191/my-idx-*-2022-09-16,-my-idx-aaa-2022-09-16-rw/_settings?pretty' | jq keys
[
  "my-idx-aaa-2022-09-16-rw",
  "my-idx-bbb-2022-09-16-rw"
]

(My scheme is that my-idx-<customer_id>-<date> is an alias for either my-idx-<customer_id>-<date>-rw or -ro, depending on whether the index has been moved to warm/read-only storage.)

It appears that you need to exclude by alias if the index matches by alias, exclude by concrete name if the index matches by concrete name, and exclude by both if both the concrete name and the alias match the pattern:

$ curl -s 'localhost:19191/my-idx-*,-my-idx-aaa-2022-09-16-rw/_settings?pretty' | jq keys 
[
  "my-idx-aaa-2022-09-16-rw",
  "my-idx-bbb-2022-09-16-rw"
]

$ curl -s 'localhost:19191/my-idx-*,-my-idx-aaa-2022-09-16/_settings?pretty' | jq keys 
[
  "my-idx-aaa-2022-09-16-rw",
  "my-idx-bbb-2022-09-16-rw"
]

$ curl -s 'localhost:19191/my-idx-*,-my-idx-aaa-2022-09-16,-my-idx-aaa-2022-09-16-rw/_settings?pretty' | jq keys
[
  "my-idx-bbb-2022-09-16-rw"
]

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