You are here

protected function SearchApiDbService::eliminateDuplicates in Search API Database Search 7

Eliminates duplicate keys from a keyword array.

Used as a helper method in prepareKeys().

Parameters

array $keys: The keywords to parse.

array $words: (optional) A cache of all encountered words so far, used internally for recursive invocations.

Return value

array The processed keywords.

1 call to SearchApiDbService::eliminateDuplicates()
SearchApiDbService::prepareKeys in ./service.inc
Removes nested expressions and phrase groupings from the search keys.

File

./service.inc, line 1458
Contains SearchApiDbService.

Class

SearchApiDbService
Indexes and searches items using the database.

Code

protected function eliminateDuplicates($keys, &$words = array()) {
  foreach ($keys as $i => $word) {
    if (!element_child($i)) {
      continue;
    }
    if (is_scalar($word)) {
      if (isset($words[$word])) {
        unset($keys[$i]);
      }
      else {
        $words[$word] = TRUE;
      }
    }
    else {
      $keys[$i] = $this
        ->eliminateDuplicates($word, $words);
    }
  }
  return $keys;
}