/** * {@inheritdoc} */ public function addBuilder(BuilderInterface $builder, $parameters = []) { if (!$this->query && !(array_key_exists('bool_type', $parameters) && !empty($parameters['bool_type']))) { $this->setBuilder($builder); } else { $parameters = $this->resolver->resolve(array_filter($parameters)); $this->isBool() ?: $this->convertToBool(); $this->query->add($builder, $parameters['bool_type']); } return $this; }
/** * {@inheritdoc} */ public function modifySearch(Search $search, FilterState $state = null, SearchRequest $request = null) { if ($state && $state->isActive()) { if (strpos($this->getField(), ',') !== false) { $subQuery = new BoolQuery(); foreach (explode(',', $this->getField()) as $field) { $subQuery->add(new FuzzyQuery($field, $state->getValue(), $this->getParameters()), 'should'); } $search->addQuery($subQuery, 'must'); } else { $search->addQuery(new FuzzyQuery($this->getField(), $state->getValue(), $this->getParameters()), 'must'); } } }