Body
- query
object - from
number The starting document offset. It must not be negative. By default, you cannot page through more than 10,000 hits using the
from
andsize
parameters. To page through more hits, use thesearch_after
parameter. - size
number The number of hits to return. It must not be negative. By default, you cannot page through more than 10,000 hits using the
from
andsize
parameters. To page through more hits, use thesearch_after
parameter. - search_after
array[number | string | boolean | null | object] A field value.
GET /_security/_query/role
curl \
--request GET 'http://api.example.com/_security/_query/role' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '"{\n \"sort\": [\"name\"]\n}"'
Request examples
Query roles by name
Run `POST /_security/_query/role` to lists all roles, sorted by the role name.
{
"sort": ["name"]
}
Run `POST /_security/_query/role` to query only the user access role, given its description. It returns only the best matching role because `size` is set to `1`.
{
"query": {
"match": {
"description": {
"query": "user access"
}
}
},
"size": 1
}
Response examples (200)
Query roles by name
A successful response from `POST /_security/_query/role`. It returns a JSON structure that contains the information retrieved for one or more roles.
{
"total": 2,
"count": 2,
"roles": [
{
"name" : "my_admin_role",
"cluster" : [
"all"
],
"indices" : [
{
"names" : [
"index1",
"index2"
],
"privileges" : [
"all"
],
"field_security" : {
"grant" : [
"title",
"body"
]
},
"allow_restricted_indices" : false
}
],
"applications" : [ ],
"run_as" : [
"other_user"
],
"metadata" : {
"version" : 1
},
"transient_metadata" : {
"enabled" : true
},
"description" : "Grants full access to all management features within the cluster.",
"_sort" : [
"my_admin_role"
]
},
{
"name" : "my_user_role",
"cluster" : [ ],
"indices" : [
{
"names" : [
"index1",
"index2"
],
"privileges" : [
"all"
],
"field_security" : {
"grant" : [
"title",
"body"
]
},
"allow_restricted_indices" : false
}
],
"applications" : [ ],
"run_as" : [ ],
"metadata" : {
"version" : 1
},
"transient_metadata" : {
"enabled" : true
},
"description" : "Grants user access to some indicies.",
"_sort" : [
"my_user_role"
]
}
]
}
A successful response from `POST /_security/_query/role`.
{
"total": 2,
"count": 1,
"roles": [
{
"name" : "my_user_role",
"cluster" : [ ],
"indices" : [
{
"names" : [
"index1",
"index2"
],
"privileges" : [
"all"
],
"field_security" : {
"grant" : [
"title",
"body"
]
},
"allow_restricted_indices" : false
}
],
"applications" : [ ],
"run_as" : [ ],
"metadata" : {
"version" : 1
},
"transient_metadata" : {
"enabled" : true
},
"description" : "Grants user access to some indicies."
}
]
}