You are here

protected function SearchApiSolrBackend::setSorts in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::setSorts()
  2. 8 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::setSorts()
  3. 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::setSorts()

Sets sorting for the query.

Parameters

\Solarium\QueryType\Select\Query\Query $solarium_query: The Solarium query.

\Drupal\search_api\Query\QueryInterface $query: The Search API query.

Throws

\Drupal\search_api\SearchApiException

1 call to SearchApiSolrBackend::setSorts()
SearchApiSolrBackend::search in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Options on $query prefixed by 'solr_param_' will be passed natively to Solr as query parameter without the prefix. For example you can set the "Minimum Should Match" parameter 'mm' to '75%' like this:

File

src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 4341

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function setSorts(Query $solarium_query, QueryInterface $query) {
  $field_names = $this
    ->getSolrFieldNamesKeyedByLanguage($this
    ->ensureLanguageCondition($query), $query
    ->getIndex());
  foreach ($query
    ->getSorts() as $field => $order) {
    $solarium_query
      ->addSort(Utility::getSortableSolrField($field, $field_names, $query), strtolower($order));
  }
}