Skip to main content
Version: 7.2402.x.x RR

Sorting the results

The Query REST Service returns the results by default in the order of the relevance of the results, which is calculated by a non-defined algorithm. If the results are needed in any other order, it is possible to define a sorting for the query.

The sorting can be appended as an URL parameter, for example:

GET https://<hostname>:<port>/nevisidm/api/query/v1/all?q=test&s=name

Examples

The sorting parameter uses the syntax of Elasticsearch, and it has to be a valid JSON array. There are different ways to define fields:

  • Providing just the field name as a string

    "name","email"
  • Providing the field name and the sorting order together in an object

    [{"name":"asc"},{"email":"desc"}]
  • Providing the field name in an object and the sorting order in a child object

    [{"name":{"order":"desc"}},{"email":{"order":"asc"}}]

Additional information

  • The currently supported fields are the user surname, first name, status, email, last login and last failed login. The field names are respectively: name, firstname, state, email, loginInfo.lastLogin and loginInfo.lastFailure
  • The possible values for the sorting order are asc for ascending order, and desc for descending order.
  • If not defined, the sorting order for the field is handled as ascending by default.
  • The different ways can be combined in a single query, for example, the simple string notation can be used for fields with the default order, and the objects can be used where the order should be descending.
  • The sorting by name, firstname and email is case-insensitive.