public function getUserIdsFromName($name, $count, $suggestion_format = SOCIAL_PROFILE_SUGGESTIONS_ALL) {
    $query = $this->startQuery();
    $name = '%' . ltrim($query->escapeLike($name)) . '%';

    switch ($suggestion_format) {
      case SOCIAL_PROFILE_SUGGESTIONS_USERNAME:
        $query->condition('uf.name', $name, 'LIKE');
        break;

      case SOCIAL_PROFILE_SUGGESTIONS_FULL_NAME:
      case SOCIAL_PROFILE_SUGGESTIONS_ALL:
        if ($this->useFullName()) {
          $strings = explode(' ', $name);

          if (count($strings) > 1) {
            $query->where("CONCAT(TRIM(fn.field_profile_first_name_value), ' ', TRIM(ln.field_profile_last_name_value)) LIKE :full_name", [
              ':full_name' => $name,
            ]);

            $query = $this->sortQuery($query, $name, $suggestion_format);
            $results = $this->endQuery($query, $count);

            if (count($results) > 0) {
              return $results;
            }

            // Fallback to creating a new query if there is no hit on full name.
            $query = $this->startQuery();
          }
        }

        $or_query = $query->orConditionGroup();

        if ($this->useFullName()) {
          $or_query
            ->condition('fn.field_profile_first_name_value', $name, 'LIKE')
            ->condition('ln.field_profile_last_name_value', $name, 'LIKE');
        }

        // Add name only when needed.
        if ($suggestion_format === SOCIAL_PROFILE_SUGGESTIONS_ALL) {
          $or_query->condition('uf.name', $name, 'LIKE');
        }

        if ($this->addNickName() === TRUE) {
          $or_query->condition('nn.field_profile_nick_name_value', $name, 'LIKE');
        }

        $query->condition($or_query);

        break;
    }

    // Now we sort the query.
    $query = $this->sortQuery($query, $name, $suggestion_format);

    return $this->endQuery($query, $count);
  }