Skip to main content

Order By

An optional ORDER BY clause can be specified to enforce the sort order of the results.

MQL supports these sort orders if the search index is a Lucene index:

  • Name [asc]: sort by name in ascending order
  • Name desc: sort by name in descending order
  • Relevance: sort by relevance, i.e. object with highest rank at the top of the results
  • "Updated Date": sort by "Updated Date" in descending order, i.e. latest first

If the search index is a Solr index, you can order your query results not only by Name, Relevance and "Updated Date" but also by other property types:

  • System attributes. Note: Only the system attributes that are stored in the search index can be used as the order by fields. Besides multi-valued system attributes such as "Data Classifications" or object-valued system attributes such as "Column Statistics" cannot be used as an order by field
  • Custom attributes. Note: Custom attributes of the Enumeration (Multi-value), Users, Rich Text, Blob, Multiline Text type, or nested fields of structure type cannot be used as an order by field. Order by a custom attribute of the User data type returns the results sorted by the user ids not by the usernames.
  • Profile attributes
  • Data Profiling attributes except the multi-valued attribute "Data Profiling"."Inferred Data Types"
  • UDPs

You can have more than one order by field in the Order By clause. Each field can be a property type in the above list with its own asc(ending) or desc(ending) order. For example, "Last Name" asc, "First Name" desc. This sorts everything by "Last Name" in the ascending order first and then by "First Name" in the descending order whenever the "Last Name" property for two or more objects are identical.

The null value is considered as the smallest value.

The sort order Relevance cannot be combined with other fields.

If the query results contain objects from multiple profiles, such as "Data Modeling" and "RDBMS Relational Database", and the order by field, such as "Data Type", exists in multiple profiles, the sort order of the results will be grouped by the profiles. For example, all the objects of the "Data Modeling" profile may appear before all the objects of the "RDBMS Relational Database" profile. Within each group the objects are ordered by the value of the order by field.

If a text filter or semantic_search_text filter is present, the default sort order is relevance; otherwise, the default sort order is Name ascending.

The property types in the Order By clause are case-sensitive.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!