diff --git a/contrib/search_api_views/includes/query.inc b/contrib/search_api_views/includes/query.inc index ce6e6b6..aceb0be 100644 --- a/contrib/search_api_views/includes/query.inc +++ b/contrib/search_api_views/includes/query.inc @@ -124,6 +124,15 @@ class SearchApiViewsQuery extends views_plugin_query { } /** + * Accept Global:Random as a sort criterion + */ + function add_orderby($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) { + if ($table == 'rand') { + $this->add_selector_orderby('search_api_random', $order); + } + } + + /** * Defines the options used by this query plugin. * * Adds an option to bypass access checks. diff --git a/includes/query.inc b/includes/query.inc index 59b5309..e3ef5db 100644 --- a/includes/query.inc +++ b/includes/query.inc @@ -615,6 +615,7 @@ class SearchApiQuery implements SearchApiQueryInterface { $fields += array( 'search_api_relevance' => array('type' => 'decimal'), 'search_api_id' => array('type' => 'integer'), + 'search_api_random' => array('type' => 'integer'), ); if (empty($fields[$field])) { throw new SearchApiException(t('Trying to sort on unknown field !field.', array('!field' => $field)));