public function SearchApiMultiQuery::preExecute in Search API Multi-Index Searches 7
Pre-execute hook for modifying search behaviour.
1 call to SearchApiMultiQuery::preExecute()
File
- ./
search_api_multi.query.inc, line 1037
Class
- SearchApiMultiQuery
- Standard implementation of SearchApiMultiQueryInterface.
Code
public function preExecute() {
// Make sure to only execute this once per query.
if (!$this->pre_execute) {
$this->pre_execute = TRUE;
// Add filter for languages.
if (isset($this->options['languages'])) {
$this
->addLanguages($this->options['languages']);
}
// Filter indexes to those used. If no index was explicitly used, include
// all of them.
if ($this->used_indexes) {
$this->indexes = array_intersect_key($this->indexes, $this->used_indexes);
}
// Add fulltext fields, unless set.
if ($this->fields === NULL) {
$this->fields = $this->index_fields = array();
foreach ($this->indexes as $index_id => $index) {
foreach ($index
->getFulltextFields() as $f) {
$this->fields[] = "{$index_id}:{$f}";
$this->index_fields[$index_id][] = $f;
}
}
}
elseif ($this->keys) {
$this->indexes = array_intersect_key($this->indexes, $this->index_fields);
}
// Filter the $servers property according to the used indexes.
foreach ($this->servers as $server_id => $indexes) {
foreach ($indexes as $index_id => $index) {
if (!isset($this->indexes[$index_id])) {
unset($this->servers[$server_id][$index_id]);
}
}
}
$this->servers = array_filter($this->servers);
}
}