Пример #1
0
 /**
  * Adds a sort directive to this search query.
  *
  * If no sort is manually set, the results will be sorted descending by
  * relevance.
  *
  * @param 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.
  * @param string $order
  *   The order to sort items in - either 'ASC' or 'DESC'.
  *
  * @return $this
  *
  * @throws \Drupal\search_api\SearchApiException
  *   Thrown if the field is multi-valued or of a fulltext type.
  *
  * @see \Drupal\search_api\Query\QueryInterface::sort()
  */
 public function sort($field, $order = 'ASC')
 {
     if (!$this->shouldAbort()) {
         $this->query->sort($field, $order);
     }
     return $this;
 }