You are here

public function SearchApiQueryInterface::sort in Search API 7

Adds a sort directive to this search query.

If no sort is manually set, the results will be sorted descending by relevance.

Parameters

string $field: The field to sort by. The special fields 'search_api_relevance' (sort by relevance) and 'search_api_id' (sort by item id) may be used. Also, if the search server supports the "search_api_random_sort" feature, the "search_api_random" special field can be used to sort randomly.

string $order: The order to sort items in - either 'ASC' or 'DESC'.

Return value

SearchApiQueryInterface The called object.

Throws

SearchApiException If the field is multi-valued or of a fulltext type.

1 method overrides SearchApiQueryInterface::sort()
SearchApiQuery::sort in includes/query.inc
Adds a sort directive to this search query.

File

includes/query.inc, line 168
Contains SearchApiQueryInterface and SearchApiQuery.

Class

SearchApiQueryInterface
Interface representing a search query on an Search API index.

Code

public function sort($field, $order = 'ASC');