search[] = array('text' => $text, 'fields' => $fields ? (array)$fields : null, 'boost' => $boost, 'fuzzy' => false); } /** * Similar to {@link search()}, but uses stemming and other similarity algorithms * to find the searched terms. For example, a term "fishing" would also likely find results * containing "fish" or "fisher". Depends on search implementation. * * @param String $text See {@link search()} * @param array $fields See {@link search()} * @param array $boost See {@link search()} */ public function fuzzysearch($text, $fields = null, $boost = array()) { $this->search[] = array('text' => $text, 'fields' => $fields ? (array)$fields : null, 'boost' => $boost, 'fuzzy' => true); } public function inClass($class, $includeSubclasses = true) { $this->classes[] = array('class' => $class, 'includeSubclasses' => $includeSubclasses); } /** * Similar to {@link search()}, but typically used to further narrow down * based on other facets which don't influence the field relevancy. * * @param String $field Composite name of the field * @param Mixed $values Scalar value, array of values, or an instance of SearchQuery_Range */ public function filter($field, $values) { $requires = isset($this->require[$field]) ? $this->require[$field] : array(); $values = is_array($values) ? $values : array($values); $this->require[$field] = array_merge($requires, $values); } /** * Excludes results which match these criteria, inverse of {@link filter()}. * * @param String $field * @param mixed $values */ public function exclude($field, $values) { $excludes = isset($this->exclude[$field]) ? $this->exclude[$field] : array(); $values = is_array($values) ? $values : array($values); $this->exclude[$field] = array_merge($excludes, $values); } public function start($start) { $this->start = $start; } public function limit($limit) { $this->limit = $limit; } public function page($page) { $this->start = $page * self::$default_page_size; $this->limit = self::$default_page_size; } public function isfiltered() { return $this->search || $this->classes || $this->require || $this->exclude; } public function __toString() { return "Search Query\n"; } }