London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Loading...

OrderBy parameter

This topic describes the OrderBy parameter, part of the GraphQL API used for the Optimizely querying service, when retrieving content in Optimizely solutions.

How it works

The orderBy parameter enables the ordering (sorting) of the result list. You can order by:

  • Relevance. Scores with _ranking, which uses BM25 for best matching, and always sorted in descending order (most relevant top).
  • Fields. Can be either sorted in DESC (descending) or ASC (ascending) order.

The orderBy can have 1 or more sorting critera. In case there is a tiebreaker, then the next sorting criteria is used, and so on.

Example

To sort by relevance, and when the scores are the same, then by a field called "created" in descending order (newest in top):

orderBy: { 
    _ranking: RELEVANCE 
    created: DESC 
}

Related topics

Last updated: May 24, 2021