# How to filter roles which are having cluster is all privileges

**URL:** https://discuss.elastic.co/t/how-to-filter-roles-which-are-having-cluster-is-all-privileges/142151
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [July 30, 2018, 10:49am UTC](https://discuss.elastic.co/t/how-to-filter-roles-which-are-having-cluster-is-all-privileges/142151 "2018-07-30T10:49:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![prabhakar\_talari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prabhakar_talari/32/46469_2.png) [@prabhakar\_talari](https://discuss.elastic.co/u/prabhakar_talari)
#### Post date: [July 30, 2018, 10:49am UTC](https://discuss.elastic.co/t/how-to-filter-roles-which-are-having-cluster-is-all-privileges/142151/1 "2018-07-30T10:49:30Z")

</div>

Hi Team,

Could any one suggest How to filter roles which are having cluster is all privileges.

Thanks in Advance.

---

<div class="post-metadata">

### Author: ![Albert\_Zaharovits](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/albert_zaharovits/32/24390_2.png) [@Albert\_Zaharovits](https://discuss.elastic.co/u/Albert_Zaharovits)
#### Post date: [August 6, 2018, 7:17am UTC](https://discuss.elastic.co/t/how-to-filter-roles-which-are-having-cluster-is-all-privileges/142151/2 "2018-08-06T07:17:06Z")

</div>

Hi @prabhakar_talari

The [list roles API](https://www.elastic.co/guide/en/x-pack/current/defining-roles.html#roles-api-list) does not allow to specify conditions for the returned roles (besides for the name, of course).

Right now, I see two solutions to this problem of filtering role descriptors, or any ES internal meta data, for that matter:

- least maintainable (portable between versions) is to query the `.security` index directly, bypassing the list roles API.
- on the client side, use [jq](https://stedolan.github.io/jq/) to parse the full output of the list roles API, and subsequently filter for the ones that match your criterion.

Both these solutions are temporal only, until the [High Level Rest Client](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high.html) matures enough to include response objects for the get roles API. ETA for this is ES version 7. Then, you will not need jq, you will iterate over the roles on the client side using methods of the response objects.  
Then this will be the sole recommended solution.

Let me know if you need help with any of the afore mentioned approaches.

---

<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 3, 2018, 7:17am UTC](https://discuss.elastic.co/t/how-to-filter-roles-which-are-having-cluster-is-all-privileges/142151/3 "2018-09-03T07:17:13Z")

</div>

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