protected function Solr_Base_Query::parse_sortstring in Apache Solr Search 6.2
Same name and namespace in other branches
- 5.2 Solr_Base_Query.php \Solr_Base_Query::parse_sortstring()
- 6 Solr_Base_Query.php \Solr_Base_Query::parse_sortstring()
3 calls to Solr_Base_Query::parse_sortstring()
- Solr_Base_Query::remove_available_sort in ./
Solr_Base_Query.php - Solr_Base_Query::set_available_sort in ./
Solr_Base_Query.php - Make a sort available.
- Solr_Base_Query::__construct in ./
Solr_Base_Query.php
File
- ./
Solr_Base_Query.php, line 265
Class
Code
protected function parse_sortstring() {
// Substitute any field aliases with real field names.
$sortstring = strtr($this->sortstring, array_flip($this->field_map));
// Score is a special case - it's the default sort for Solr.
if ('' == $sortstring) {
$this
->set_solrsort('score', 'desc');
}
else {
// Validate and set sort parameter
$fields = implode('|', array_keys($this->available_sorts));
if (preg_match('/^(?:(' . $fields . ') (asc|desc),?)+$/', $sortstring, $matches)) {
// We only use the last match.
$this
->set_solrsort($matches[1], $matches[2]);
}
}
}