You are here

interface SearchApiQueryFilterInterface in Search API 7

Represents a filter on a search query.

Filters apply conditions on one or more fields with a specific conjunction (AND or OR) and may contain nested filters.

Hierarchy

Expanded class hierarchy of SearchApiQueryFilterInterface

All classes that implement SearchApiQueryFilterInterface

File

includes/query.inc, line 894
Contains SearchApiQueryInterface and SearchApiQuery.

View source
interface SearchApiQueryFilterInterface {

  /**
   * Constructs a new filter that uses the specified conjunction.
   *
   * @param string $conjunction
   *   (optional) The conjunction to use for this filter - either 'AND' or 'OR'.
   * @param array $tags
   *   (optional) An arbitrary set of tags. Can be used to identify this filter
   *   down the line if necessary. This is primarily used by the facet system
   *   to support OR facet queries.
   */
  public function __construct($conjunction = 'AND', array $tags = array());

  /**
   * Sets this filter's conjunction.
   *
   * @param string $conjunction
   *   The conjunction to use for this filter - either 'AND' or 'OR'.
   *
   * @return SearchApiQueryFilterInterface
   *   The called object.
   */
  public function setConjunction($conjunction);

  /**
   * Adds a subfilter.
   *
   * @param SearchApiQueryFilterInterface $filter
   *   A SearchApiQueryFilterInterface object that should be added as a
   *   subfilter.
   *
   * @return SearchApiQueryFilterInterface
   *   The called object.
   */
  public function filter(SearchApiQueryFilterInterface $filter);

  /**
   * Adds a new ($field $operator $value) condition.
   *
   * @param string $field
   *   The field to filter on, e.g. 'title'.
   * @param mixed $value
   *   The value the field should have (or be related to by the operator).
   * @param 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 SearchApiQueryFilterInterface
   *   The called object.
   */
  public function condition($field, $value, $operator = '=');

  /**
   * Retrieves the conjunction used by this filter.
   *
   * @return string
   *   The conjunction used by this filter - either 'AND' or 'OR'.
   */
  public function getConjunction();

  /**
   * Return all conditions and nested filters contained in this filter.
   *
   * @return array
   *   An array containing this filter's subfilters. Each of these is either a
   *   condition, represented as a numerically indexed array with the arguments
   *   of a previous SearchApiQueryFilterInterface::condition() call (field,
   *   value, operator); or a nested filter, represented by a
   *   SearchApiQueryFilterInterface filter object.
   */
  public function &getFilters();

  /**
   * Checks whether a certain tag was set on this filter.
   *
   * @param string $tag
   *   A tag to check for.
   *
   * @return bool
   *   TRUE if the tag was set for this filter, FALSE otherwise.
   */
  public function hasTag($tag);

  /**
   * Retrieves the tags set on this filter.
   *
   * @return array
   *   The tags associated with this filter, as both the array keys and values.
   */
  public function &getTags();

}

Members

Namesort descending Modifiers Type Description Overrides
SearchApiQueryFilterInterface::condition public function Adds a new ($field $operator $value) condition. 1
SearchApiQueryFilterInterface::filter public function Adds a subfilter. 1
SearchApiQueryFilterInterface::getConjunction public function Retrieves the conjunction used by this filter. 1
SearchApiQueryFilterInterface::getFilters public function Return all conditions and nested filters contained in this filter. 1
SearchApiQueryFilterInterface::getTags public function Retrieves the tags set on this filter. 1
SearchApiQueryFilterInterface::hasTag public function Checks whether a certain tag was set on this filter. 1
SearchApiQueryFilterInterface::setConjunction public function Sets this filter's conjunction. 1
SearchApiQueryFilterInterface::__construct public function Constructs a new filter that uses the specified conjunction. 1