You are here

protected function FuzzySearchService::splitKeys in Fuzzy Search 7

Helper method for splitting keys.

1 call to FuzzySearchService::splitKeys()
FuzzySearchService::prepareKeys in includes/service.inc
Helper method for removing unnecessary nested expressions from keys.

File

includes/service.inc, line 890

Class

FuzzySearchService
Search service class using the database for storing index information.

Code

protected function splitKeys($keys) {
  if (is_scalar($keys)) {
    $proc = drupal_strtolower(trim($keys));
    if (is_numeric($proc)) {
      $proc = ltrim($proc, '-');
    }
    if (drupal_strlen($proc) < $this->options['min_chars']) {
      $this->ignored[$keys] = 1;
      return NULL;
    }
    $words = preg_split('/[^\\p{L}\\p{N}]+/u', $proc, -1, PREG_SPLIT_NO_EMPTY);
    if (count($words) > 1) {
      $proc = $this
        ->splitKeys($words);
      $proc['#conjunction'] = 'AND';
    }
    return $proc;
  }
  foreach ($keys as $i => $key) {
    if (element_child($i)) {
      $keys[$i] = $this
        ->splitKeys($key);
    }
  }
  return array_filter($keys);
}