You are here

function search_api_live_results_views_query in Search API live results 7

Create the query that would be issued for the given search for the complete keys.

Parameters

SearchApiLiveResultsSearch $search: The search for which to create the query.

$complete: A string containing the complete search keys.

$incomplete: A string containing the incomplete last search key.

Return value

SearchApiQueryInterface The query that would normally be executed when only $complete was entered as the search keys for the given search.

1 string reference to 'search_api_live_results_views_query'
search_api_live_results_search_api_live_results_types in ./search_api_live_results.module
Implements hook_search_api_live_results_types().

File

./search_api_live_results.search_api_views.inc, line 87
Contains code for integrating with the "Search views" module.

Code

function search_api_live_results_views_query(SearchApiLiveResultsSearch $search, $complete, $incomplete) {
  $views_id = substr($search->machine_name, 17);
  $view = views_get_view($views_id);

  // @todo Let users select display
  $view
    ->set_display();

  // @todo Determine arguments
  $view
    ->pre_execute();
  $view
    ->build();
  $query = $view->query
    ->getSearchApiQuery();
  $query
    ->keys($complete);
  return $query;
}