public function SearchApiMultiQuery::condition in Search API Multi-Index Searches 7
Add a new ($field $operator $value) condition filter.
Parameters
string $field: The field to filter on. Either a field specification as detailed in the class comment, or the special field "search_api_multi_index" which means a filter on the searched indexes.
mixed $value: The value the field should have (or be related to by the operator).
string $operator: The operator to use for checking the constraint. The following operators are supported for primitive types: "=", "<>", "<", "<=", ">=", ">". They have the same semantics as the corresponding SQL operators. If $field is a fulltext field, $operator can only be "=" or "<>", which are in this case interpreted as "contains" or "doesn't contain", respectively. If $value is NULL, $operator also can only be "=" or "<>", meaning the field must have no or some value, respectively.
Return value
SearchApiMultiQueryInterface The called object.
Overrides SearchApiMultiQueryInterface::condition
File
- ./
search_api_multi.query.inc, line 621
Class
- SearchApiMultiQuery
- Standard implementation of SearchApiMultiQueryInterface.
Code
public function condition($field, $value, $operator = '=') {
if ($field == 'search_api_multi_index') {
if ($operator == '=') {
if (isset($this->indexes[$value])) {
$this->indexes = array(
$value => $this->indexes[$value],
);
}
else {
throw new SearchApiException(t('Trying to filter multi-index query on two indexes simultaneously.'));
}
}
else {
unset($this->indexes[$value]);
}
}
else {
$this->filter
->condition($field, $value, $operator);
if ($operator != '<>' && strpos($field, ':')) {
list($index_id) = explode(':', $field, 2);
$this->used_indexes[$index_id] = TRUE;
}
}
return $this;
}