# Documentation Error RE: elasticsearch multi-target syntax

**URL:** <https://discuss.elastic.co/t/documentation-error-re-elasticsearch-multi-target-syntax/312233>\
**Category:** Elasticsearch\
**Created:** [August 17, 2022, 1:11am UTC](https://discuss.elastic.co/t/documentation-error-re-elasticsearch-multi-target-syntax/312233 "2022-08-17T01:11:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_DS](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Andrew\_DS](https://discuss.elastic.co/u/Andrew_DS)\
**Post date:** [August 17, 2022, 1:11am UTC](https://discuss.elastic.co/t/documentation-error-re-elasticsearch-multi-target-syntax/312233/1 "2022-08-17T01:11:14Z")

</div>

In the [API Conventions Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/api-conventions.html#api-multi-index), 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.

```auto
$ 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:

```auto
$ 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"
]

```

---

<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:** [September 14, 2022, 1:12am UTC](https://discuss.elastic.co/t/documentation-error-re-elasticsearch-multi-target-syntax/312233/2 "2022-09-14T01:12:02Z")

</div>

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