# Exclude indices from Elastic Search role

**URL:** <https://discuss.elastic.co/t/exclude-indices-from-elastic-search-role/244159>\
**Category:** Kibana\
**Tags:** elastic-stack-security\
**Created:** [August 7, 2020, 10:55am UTC](https://discuss.elastic.co/t/exclude-indices-from-elastic-search-role/244159 "2020-08-07T10:55:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amjadbrsc](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@amjadbrsc](https://discuss.elastic.co/u/amjadbrsc)\
**Post date:** [August 7, 2020, 10:55am UTC](https://discuss.elastic.co/t/exclude-indices-from-elastic-search-role/244159/1 "2020-08-07T10:55:57Z")

</div>

Hi, I have 20 indices. These indices has different naming convention. I am trying to define a ES role where a user can have access to 19 indices except one.  
I can define a role and mention all 19 indices in the role one by one. But is there any way to exclude a single index from the role instead of mentioning all 19 one by one. Thanks

---

<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:** [August 9, 2020, 10:59pm UTC](https://discuss.elastic.co/t/exclude-indices-from-elastic-search-role/244159/2 "2020-08-09T22:59:42Z")

</div>

Welcome to our community! 😃

There's not, no. It sounds like a great feature request if you would like to raise it on GitHub.

---

<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:** [August 11, 2020, 2:15am UTC](https://discuss.elastic.co/t/exclude-indices-from-elastic-search-role/244159/3 "2020-08-11T02:15:32Z")

</div>

This is possible today, but it's not very friendly.

An index name pattern within a role can use a Lucene regular expression. Lucene regex can do _complements_, which allows you to do what you're asking, but it's an ugly syntax.

If you want a role that grants access to everything _except_ the `fooble` or `woz` indices, then you would define:

```auto
{
  "indices": [
    {
      "names": [
        "/~(fooble|woz)/"
      ],
      "privileges": ["all"]
    }
  ]
}

```

See also: [https://github.com/elastic/elasticsearch/issues/29907](https://github.com/elastic/elasticsearch/issues/29907)

---

<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:** [August 11, 2020, 3:05am UTC](https://discuss.elastic.co/t/exclude-indices-from-elastic-search-role/244159/4 "2020-08-11T03:05:30Z")

</div>

> [@TimV](#):
>
> This is possible today, but it's not very friendly.

Oh, neat. Thanks for sharing that 😃

---

<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 8, 2020, 3:05am UTC](https://discuss.elastic.co/t/exclude-indices-from-elastic-search-role/244159/5 "2020-09-08T03:05:32Z")

</div>

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