# Sort users by metadata field

**URL:** <https://community.auth0.com/t/sort-users-by-metadata-field/8092>\
**Category:** Get Help\
**Tags:** sort, users, metadata, search, list\
**Created:** [September 5, 2017, 9:42pm UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092 "2017-09-05T21:42:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![darryn.campbell](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@darryn.campbell](https://community.auth0.com/u/darryn.campbell)\
**Post date:** [September 5, 2017, 9:42pm UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/1 "2017-09-05T21:42:51Z")

</div>

Not sure if this is related to the recent issues with the users search API or not, but I used to be able to make a users query and specify a field from the user\_metadata as a sort criterion (e.g. “user\_metadata.first\_name:1”), but now that query, even just in the API explorer, is throwing a 503 error (“Failed to perform search”). Has a change been made recently that prevents sorting by metadata fields, or should I still be able to do this?

---

<div class="post-metadata">

**Author:** ![George\_Frivolt](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@George\_Frivolt](https://community.auth0.com/u/George_Frivolt)\
**Post date:** [September 6, 2017, 5:24pm UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/2 "2017-09-06T17:24:55Z")

</div>

I see similar issue. Sorting users by nested attributes returns 400 error:

```
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Failed to perform search. Make sure the query \"app_metadata.deleted:false AND app_metadata.admin:false\" is valid"
}

```

Also when I try to search for a nested attributes, eg. “app\_metadata.deleted:false AND app\_metadata.admin:false” without any sorting set does not return anything.

---

<div class="post-metadata">

**Author:** ![darryn.campbell](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@darryn.campbell](https://community.auth0.com/u/darryn.campbell)\
**Post date:** [September 7, 2017, 12:54am UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/3 "2017-09-07T00:54:11Z")

</div>

Per the [incident report](https://status.auth0.com/incidents/71nlbr16j7ng) for the issue mentioned in the OP:

- Sorting (`sort=...`) is not working but we are working on a fix that should be deployed in the following days.

---

<div class="post-metadata">

**Author:** ![George\_Frivolt](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@George\_Frivolt](https://community.auth0.com/u/George_Frivolt)\
**Post date:** [September 6, 2017, 5:24pm UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/4 "2017-09-06T17:24:55Z")

</div>

I see similar issue. Sorting users by nested attributes returns 400 error:

```
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Failed to perform search. Make sure the query \"app_metadata.deleted:false AND app_metadata.admin:false\" is valid"
}

```

Also when I try to search for a nested attributes, eg. “app\_metadata.deleted:false AND app\_metadata.admin:false” without any sorting set does not return anything.

---

<div class="post-metadata">

**Author:** ![graham.seccombe](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@graham.seccombe](https://community.auth0.com/u/graham.seccombe)\
**Post date:** [October 2, 2017, 6:23pm UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/5 "2017-10-02T18:23:21Z")

</div>

We have a same issue and same error message given when we include the ‘&sort=’ param in our search users query. The query works if the sort param is removed from the query but always fails if ‘&sort=’ is included. Also… this strangely only occurs with one of our tenants. In the other tenant the search query works fine even with the sort param included.

---

<div class="post-metadata">

**Author:** ![George\_Frivolt](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@George\_Frivolt](https://community.auth0.com/u/George_Frivolt)\
**Post date:** [October 2, 2017, 7:00pm UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/6 "2017-10-02T19:00:32Z")

</div>

Is there any update on that? I’ve tested it few days ago, it was still not working.

---

<div class="post-metadata">

**Author:** ![nate\_auth0.prd](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@nate\_auth0.prd](https://community.auth0.com/u/nate_auth0.prd)\
**Post date:** [November 21, 2017, 10:51pm UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/7 "2017-11-21T22:51:46Z")

</div>

Any follow up on this? Sorting by the normalized fields doesn’t work either.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/sort-users-by-metadata-field/8092/8 "2018-03-02T05:56:20Z")

</div>


