Brightspot CMS Developer Guide


The Query API includes a variety of sort-related methods to order search results by field. Sorted fields must be indexes.

Two common sorts are performed with the sortAscending and sortDescending methods. The following query sorts Author objects in descending alphabetical order by last name:

List<Author> authors = Query.from(Author.class).sortDescending("lastName");

For spatial queries for objects containing a Location field, you can use sortClosest or sortFarthest. These methods sort results in closet or farthest order from a given location.

For advanced sorting, you can use the sortNewest, sortOldest, and sortRelevant methods, which prioritize a specified field value with a specified weight.

All of the sort-related methods use the Sorter class. You can create a custom Sorter class and add it to the Query instance with the sort method.

Previous Topic
Object references
Next Topic
Was this topic helpful?
Thanks for your feedback.
The elements that get you up and running in a matter of days, from pre-built content types, to modules, to landing pages.

Content types
Landing pages
Everything you need to manage and administer content within Brightspot CMS, including plug-and-play integrations.

Admin configurations
A guide for installing, supporting and administering code on the Brightspot platform, including integrations requiring developer support to use.

Field types
Content modeling
Rich-text elements