function _search_api_get_items_on_server in Search API 7
Determines the number of items indexed on a server for a certain index.
Used as a helper function in search_api_admin_index_view().
Parameters
SearchApiIndex $index: The index
Return value
int The number of items found on the server for this index, if the latter is enabled. 0 otherwise.
Throws
SearchApiException If an error prevented the search from completing.
1 call to _search_api_get_items_on_server()
- search_api_admin_index_view in ./
search_api.admin.inc - Page callback for displaying an index's status.
File
- ./
search_api.module, line 3267 - Provides a flexible framework for implementing search services.
Code
function _search_api_get_items_on_server(SearchApiIndex $index) {
if (!$index->enabled) {
return 0;
}
// We want the raw count, without facets or other filters. Therefore we don't
// use the query's execute() method but pass it straight to the server for
// evaluation. Since this circumvents the normal preprocessing, which sets the
// fields (on which some service classes might even rely when there are no
// keywords), we set them manually here.
$query = $index
->query()
->fields(array())
->range(0, 0);
$response = $index
->server()
->search($query);
return $response['result count'];
}