diff --git a/src/Solr/SolrHelper.php b/src/Solr/SolrHelper.php index 1afbd22..ee38d62 100644 --- a/src/Solr/SolrHelper.php +++ b/src/Solr/SolrHelper.php @@ -748,7 +748,6 @@ class SolrHelper { public function setSorts(Query $solarium_query, QueryInterface $query, $field_names = array()) { $new_schema_version = version_compare($this->getSchemaVersion(), '4.4', '>='); foreach ($query->getSorts() as $field => $order) { - $f = ''; // The default Solr schema provides a virtual field named "random_SEED" // that can be used to randomly sort the results; the field is available // only at query-time. @@ -757,27 +756,27 @@ class SolrHelper { // Random seed: getting the value from parameters or computing a new // one. $seed = !empty($params['seed']) ? $params['seed'] : mt_rand(); - $f = 'random_' . $seed; + $sort_field = 'random_' . $seed; } elseif ($field == 'search_api_relevance') { - $f = $field_names[$field]; + $sort_field = $field_names[$field]; } elseif ($new_schema_version && (strpos($field_names[$field], 't') === 0 || strpos($field_names[$field], 's') === 0)) { // For fulltext fields use the dedicated sort field for faster alpha // sorts. Use the same field for strings to sort on a normalized value. - $f = 'sort_' . $field; + $sort_field = 'sort_' . $field; } elseif ($new_schema_version && preg_match('/^([a-z]+)m(_.*)/', $field_names[$field], $matches)) { // For multi-valued fields (which aren't sortable by nature) we use // the same hackish workaround like the DB backend: just copy the // first value in a single value field for sorting. - $f = $matches[1] . 's' . $matches[2]; + $sort_field = $matches[1] . 's' . $matches[2]; } else { - $f = $field_names[$field]; + $sort_field = $field_names[$field]; } - $solarium_query->addSort($f, strtolower($order)); + $solarium_query->addSort($sort_field, strtolower($order)); } }