All methods and paths for this operation:
Get information for users in a paginated manner. You can optionally filter the results with a query.
NOTE: As opposed to the get user API, built-in users are excluded from the result. This API is only for native users.
read_securityA query to filter which users to return.
If the query parameter is missing, it is equivalent to a match_all query.
The query supports a subset of query types, including match_all, bool, term, terms, match,
ids, prefix, wildcard, exists, range, and simple_query_string.
You can query the following information associated with user: username, roles, enabled, full_name, and email.
The starting document offset.
It must not be negative.
By default, you cannot page through more than 10,000 hits using the from and size parameters.
To page through more hits, use the search_after parameter.
Default value is 0.
The sort definition.
Fields eligible for sorting are: username, roles, enabled.
In addition, sort can also be applied to the _doc field to sort by index order.
The sort definition.
Fields eligible for sorting are: username, roles, enabled.
In addition, sort can also be applied to the _doc field to sort by index order.
The sort definition.
Fields eligible for sorting are: username, roles, enabled.
In addition, sort can also be applied to the _doc field to sort by index order.
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 and size parameters.
To page through more hits, use the search_after parameter.
Default value is 10.
The search after definition
A field value.
A field value.
POST /_security/_query/user?with_profile_uid=true
{
"query": {
"prefix": {
"roles": "other"
}
}
}
resp = client.security.query_user(
with_profile_uid=True,
query={
"prefix": {
"roles": "other"
}
},
)
const response = await client.security.queryUser({
with_profile_uid: "true",
query: {
prefix: {
roles: "other",
},
},
});
response = client.security.query_user(
with_profile_uid: "true",
body: {
"query": {
"prefix": {
"roles": "other"
}
}
}
)
$resp = $client->security()->queryUser([
"with_profile_uid" => "true",
"body" => [
"query" => [
"prefix" => [
"roles" => "other",
],
],
],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"query":{"prefix":{"roles":"other"}}}' "$ELASTICSEARCH_URL/_security/_query/user?with_profile_uid=true"
client.security().queryUser(q -> q
.query(qu -> qu
.prefix(p -> p
.field("roles")
.value("other")
)
)
.withProfileUid(true)
);
{
"query": {
"prefix": {
"roles": "other"
}
}
}
{
"query": {
"bool": {
"must": [
{
"wildcard": {
"email": "*example.com"
}
},
{
"term": {
"enabled": true
}
}
],
"filter": [
{
"wildcard": {
"roles": "*other*"
}
}
]
}
},
"from": 1,
"size": 2,
"sort": [
{ "username": { "order": "desc"} }
]
}
{
"total": 1,
"count": 1,
"users": [
{
"username": "jacknich",
"roles": [
"admin",
"other_role1"
],
"full_name": "Jack Nicholson",
"email": "jacknich@example.com",
"metadata": {
"intelligence": 7
},
"enabled": true,
"profile_uid": "u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0"
}
]
}
{
"total": 5,
"count": 2,
"users": [
{
"username": "ray",
"roles": [
"other_role3"
],
"full_name": "Ray Nicholson",
"email": "rayn@example.com",
"metadata": {
"intelligence": 7
},
"enabled": true,
"_sort": [
"ray"
]
},
{
"username": "lorraine",
"roles": [
"other_role3"
],
"full_name": "Lorraine Nicholson",
"email": "lorraine@example.com",
"metadata": {
"intelligence": 7
},
"enabled": true,
"_sort": [
"lorraine"
]
}
]
}
{
"total": 2,
"count": 2,
"users": [
{
"username": "jacknich",
"roles": [
"admin",
"other_role1"
],
"full_name": "Jack Nicholson",
"email": "jacknich@example.com",
"metadata": {
"intelligence": 7
},
"enabled": true
},
{
"username": "sandrakn",
"roles": [
"admin",
"other_role1"
],
"full_name": "Sandra Knight",
"email": "sandrakn@example.com",
"metadata": {
"intelligence": 7
},
"enabled": true
}
]
}