protected function SearchApiHighlight::getKeywords in Search API 7
Extracts the positive keywords used in a search query.
Parameters
SearchApiQuery $query: The query from which to extract the keywords.
Return value
array An array of all unique positive keywords used in the query.
1 call to SearchApiHighlight::getKeywords()
- SearchApiHighlight::postprocessSearchResults in includes/
processor_highlight.inc - Does nothing.
File
- includes/
processor_highlight.inc, line 258 - Contains the SearchApiHighlight class.
Class
- SearchApiHighlight
- Processor for highlighting search results.
Code
protected function getKeywords(SearchApiQuery $query) {
$keys = $query
->getKeys();
if (!$keys) {
return array();
}
if (is_array($keys)) {
return $this
->flattenKeysArray($keys);
}
$keywords = preg_split(self::$split, $keys);
// Assure there are no duplicates. (This is actually faster than
// array_unique() by a factor of 3 to 4.)
$keywords = drupal_map_assoc(array_filter($keywords));
// Remove quotes from keywords.
foreach ($keywords as $key) {
$keywords[$key] = trim($key, "'\" ");
}
return drupal_map_assoc(array_filter($keywords));
}