Intro

SortClauses are the sorting options for Content and Location Search in "Platform stack", for generic use of API Search see Search Criterions and Sort Clauses

SortClause consists of two parts just like Criterion and FacetBuilder:

The SortClause represent the value you use in the API, while SortClauseHandler deals with the business logic in the background translating the value to something the Search engine can understand.

Implantation and availability of a handler sometimes depends on SearchEngine capabilities/limitations.

Common concepts for all SortClauses

For how to use each and every SortClause see list below as it depends on the SortClause Value constructor, but in general you should be aware of the following common concept:

List of SortClauses

The list below reflects SortClauses available in eZ\Publish\API\Repository\Values\Content\Query\SortClause namespace (it is also possible to make custom SortClause):

Arguments starting with "?" are optional.

Only for LocationSearch

SortClauseConstructor arguments description
Location\Depth ?sortDirection
Location\Id ?sortDirection
Location\IsMainLocation ?sortDirection
Location\Depth ?sortDirection
Location\Priority ?sortDirection
Location\Visibility ?sortDirection

Only for ContentSearch

SortClauseConstructor arguments description
LocationDepth Use LocationSearch with Location\Depth, since LocationDepth can give unpredictable results when content has several locations.
LocationPath  
LocationPathString  
LocationPriority Use LocationSearch with Location\Priority, since LocationPriority can give unpredictable results when content has several locations.

Common

SortClauseConstructor arguments description
ContentId?sortDirection
ContentName?sortDirection
DateModified?sortDirection
DatePublished?sortDirection
Field

typeIdentifier as string, fieldIdentifier as string, ?sortDirection, ?languageCode as string

MapLocationDistance typeIdentifier as string, fieldIdentifier as string, latitude as float, longitude as float, ?sortDirection, ?languageCode as string
SectionIdentifier ?sortDirection
SectionName ?sortDirection