diff --git a/contrib/search_api_views/README.txt b/contrib/search_api_views/README.txt index 9e41763..b36a7b5 100644 --- a/contrib/search_api_views/README.txt +++ b/contrib/search_api_views/README.txt @@ -26,7 +26,19 @@ should all work normally. "Random sort" feature --------------------- -@todo Description +This module defines the "Random sort" feature (feature key: +"search_api_random_sort") that allows to randomly sort the results returned by a +search. With a server supporting this, you can use the "Global: Random" sort to +sort the view's results randomly. Every time the query is run a different +sorting will be provided. + +For developers: +A service class that wants to support this feature has to check for a +"search_api_random" field in the search query's sorts and insert a random sort +in that position. If the query is sorted in this way, then the +"search_api_random_sort" query option can contain additional options for the +random sort, as an associative array with any of the following keys: +- seed: A numeric seed value to use for the random sort. "Facets block" display ---------------------- diff --git a/contrib/search_api_views/includes/query.inc b/contrib/search_api_views/includes/query.inc index 1b66b67..923570b 100644 --- a/contrib/search_api_views/includes/query.inc +++ b/contrib/search_api_views/includes/query.inc @@ -129,8 +129,8 @@ class SearchApiViewsQuery extends views_plugin_query { * In addition, these special fields may be used: * - search_api_relevance: sort by relevance; * - search_api_id: sort by item id; - * - search_api_random_sort: random sort (available only if the server - * supports the "search_api_random_sort" feature). + * - search_api_random: random sort (available only if the server supports + * the "search_api_random_sort" feature). * @param string $order * The order to sort items in - either 'ASC' or 'DESC'. Defaults to 'ASC'. */ @@ -167,7 +167,7 @@ class SearchApiViewsQuery extends views_plugin_query { $server = $this->getIndex()->server(); if ($table == 'rand') { if ($server->supportsFeature('search_api_random_sort')) { - $this->add_selector_orderby('search_api_random_sort', $order); + $this->add_selector_orderby('search_api_random', $order); if ($params) { $this->setOption('search_api_random_sort', $params); } diff --git a/includes/query.inc b/includes/query.inc index 771446e..1935ff0 100644 --- a/includes/query.inc +++ b/includes/query.inc @@ -589,7 +589,7 @@ class SearchApiQuery implements SearchApiQueryInterface { 'search_api_id' => array('type' => 'integer'), ); if ($this->getIndex()->server()->supportsFeature('search_api_random_sort')) { - $fields['search_api_random_sort'] = array('type' => 'integer'); + $fields['search_api_random'] = array('type' => 'integer'); } if (empty($fields[$field])) {