function search_api_autocomplete_pages_query in Search API Autocomplete 7
Create the query that would be issued for the given search for the complete keys.
Parameters
SearchApiAutocompleteSearch $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.
Throws
SearchApiException If the query couldn't be created.
1 string reference to 'search_api_autocomplete_pages_query'
File
- ./
search_api_autocomplete.search_api_page.inc, line 66 - Contains code for integrating with the "Search pages" module.
Code
function search_api_autocomplete_pages_query(SearchApiAutocompleteSearch $search, $complete, $incomplete) {
$page = search_api_page_load($search->options['custom']['page_id']);
// Copied from search_api_page_search_execute().
$options = array(
'search id' => 'search_api_page:' . $page->path,
'search_api_page id' => $page->machine_name,
'parse mode' => $page->options['mode'],
);
$query = search_api_query($page->index_id, $options)
->keys($complete);
if (!empty($page->options['fields'])) {
$query
->fields($page->options['fields']);
}
if (!empty($page->options['language_filter'])) {
module_load_include('pages.inc', 'search_api_page');
$languages = array_unique(array_map('_search_api_page_map_languages', $page->options['language_filter']));
if (count($languages) == 1) {
$query
->condition('search_api_language', reset($languages));
}
else {
$filter = $query
->createFilter('OR');
foreach ($languages as $lang) {
$filter
->condition('search_api_language', $lang);
}
$query
->filter($filter);
}
}
return $query;
}