You are here

public function SearchApiFulltext::query in Search API 8

Same name in this branch
  1. 8 src/Plugin/views/filter/SearchApiFulltext.php \Drupal\search_api\Plugin\views\filter\SearchApiFulltext::query()
  2. 8 src/Plugin/views/argument/SearchApiFulltext.php \Drupal\search_api\Plugin\views\argument\SearchApiFulltext::query()

Set up the query for this argument.

The argument sent may be found at $this->argument.

Overrides SearchApiStandard::query

File

src/Plugin/views/argument/SearchApiFulltext.php, line 136

Class

SearchApiFulltext
Defines a contextual filter for doing fulltext searches.

Namespace

Drupal\search_api\Plugin\views\argument

Code

public function query($group_by = FALSE) {
  if ($this->options['parse_mode']) {
    $parse_mode = $this
      ->getParseModeManager()
      ->createInstance($this->options['parse_mode']);
    $this->query
      ->setParseMode($parse_mode);
  }
  $this->query
    ->getParseMode()
    ->setConjunction($this->options['conjunction']);
  if ($this->options['fields']) {
    $this->query
      ->setFulltextFields($this->options['fields']);
  }
  $old = $this->query
    ->getOriginalKeys();
  $this->query
    ->keys($this->argument);
  if ($old) {
    $keys =& $this->query
      ->getKeys();
    if (is_array($keys)) {
      $keys[] = $old;
    }
    elseif (is_array($old)) {

      // We don't support such nonsense.
    }
    else {
      $keys = "({$old}) ({$keys})";
    }
  }
}