addParameter example

/** * {@inheritdoc} */
    public function handle(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $aggregation = new TermsAggregation('properties');
        $aggregation->setField('properties.id');
        $aggregation->addParameter('size', self::AGGREGATION_SIZE);
        $search->addAggregation($aggregation);
    }

    /** * {@inheritdoc} */
    public function hydrate(
        array $elasticResult,
        ProductNumberSearchResult $result,
        Criteria $criteria,
        ShopContextInterface $context
    )
            new MatchQuery('fullText', $term['boost' => 5]), // whole word matches             new MatchQuery('fullText', $term['fuzziness' => 'auto', 'boost' => 3]), // word matches not exactly =>             new MatchPhrasePrefixQuery('fullText', $term['boost' => 1, 'slop' => 5]), // one of the words begins with: "Spachtel" => "Spachtelmasse"             new WildcardQuery('fullText', '*' . mb_strtolower($term) . '*'), // part of a word matches: "masse" => "Spachtelmasse"             new MatchQuery('fullText.ngram', $term),
        ];

        foreach ($queries as $query) {
            $bool->add($query, BoolQuery::SHOULD);
        }

        $bool->addParameter('minimum_should_match', 1);

        return $bool;
    }

    protected function stripText(string $text): string
    {
        // Remove all html elements to save up space         $text = strip_tags($text);

        if (mb_strlen($text) >= 32766) {
            return mb_substr($text, 0, 32766);
        }
$this->criteriaParts[] = $criteriaPart;

        switch ($criteriaPart->getMode()) {
            case ProductAttributeFacet::MODE_VALUE_LIST_RESULT:
            case ProductAttributeFacet::MODE_RADIO_LIST_RESULT:
                if ($type === 'string') {
                    $field .= '.raw';
                }
                $aggregation = new TermsAggregation($criteriaPart->getName());
                $aggregation->setField($field);
                $aggregation->addParameter('size', self::AGGREGATION_SIZE);
                break;

            case ProductAttributeFacet::MODE_BOOLEAN_RESULT:
                $count = new ValueCountAggregation($criteriaPart->getName() . '_count');
                $count->setField($field);

                $aggregation = new FilterAggregation($criteriaPart->getName());
                $aggregation->setFilter(new ExistsQuery($field));
                $aggregation->addAggregation($count);
                break;

            


    public function getType(string $key)
    {
        return $this->types[$key] ?: null;
    }

    public function merge(self $toMerge): ParseResult
    {
        $merged = new self();
        foreach ($this->parameters as $key => $parameter) {
            $merged->addParameter($key$parameter$this->types[$key]);
        }
        foreach ($this->wheres as $where) {
            $merged->addWhere($where);
        }

        foreach ($toMerge->getParameters() as $key => $parameter) {
            $merged->addParameter($key$parameter$toMerge->getType($key));
        }
        foreach ($toMerge->getWheres() as $where) {
            $merged->addWhere($where);
        }

        

        if ($aggregation->getSorting() === null) {
            $terms = new Bucketing\TermsAggregation($aggregation->getName()$fieldName);

            if ($nested = $aggregation->getAggregation()) {
                $terms->addAggregation(
                    $this->parseNestedAggregation($nested$definition$context)
                );
            }

            // set default size to 10.000 => max for default configuration             $terms->addParameter('size', ElasticsearchHelper::MAX_SIZE_VALUE);

            if ($aggregation->getLimit()) {
                $terms->addParameter('size', (string) $aggregation->getLimit());
            }

            return $terms;
        }

        $composite = new CompositeAggregation($aggregation->getName());

        $accessor = $this->buildAccessor($definition$aggregation->getSorting()->getField()$context);

        
public function __construct(array $maxExpansions)
    {
        $this->maxExpansions = $maxExpansions;
    }

    /** * {@inheritdoc} */
    public function buildQuery(ShopContextInterface $context$term)
    {
        $boolQuery = new BoolQuery();
        $boolQuery->addParameter('minimum_should_match', 1);
        $boolQuery->add($this->getBestFieldQuery($term), BoolQuery::SHOULD);
        foreach ($this->maxExpansions as $field => $maxExpansion) {
            $boolQuery->add($this->getPhrasePrefixQuery($term$field$maxExpansion), BoolQuery::SHOULD);
        }

        return $boolQuery;
    }

    private function getBestFieldQuery(string $term): MultiMatchQuery
    {
        return new MultiMatchQuery(
            [
/** * {@inheritdoc} */
    public function handle(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $aggregation = new TermsAggregation('category');
        $aggregation->setField('categoryIds');
        $aggregation->addParameter('size', self::AGGREGATION_SIZE);
        $search->addAggregation($aggregation);
    }

    /** * {@inheritdoc} */
    public function hydrate(
        array $elasticResult,
        ProductNumberSearchResult $result,
        Criteria $criteria,
        ShopContextInterface $context
    )
/** * {@inheritdoc} */
    public function handle(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $aggregation = new TermsAggregation('manufacturer');
        $aggregation->setField('manufacturer.id');
        $aggregation->addParameter('size', self::AGGREGATION_SIZE);
        $search->addAggregation($aggregation);
    }

    /** * {@inheritdoc} */
    public function hydrate(
        array $elasticResult,
        ProductNumberSearchResult $result,
        Criteria $criteria,
        ShopContextInterface $context
    )
return;
        }

        $bool = new BoolQuery();

        foreach ($queries as $query) {
            $parsed = $this->parser->parseFilter($query->getQuery()$definition$definition->getEntityName()$context);

            if ($parsed instanceof MatchQuery) {
                $score = (string) $query->getScore();

                $parsed->addParameter('boost', $score);
                $parsed->addParameter('fuzziness', '2');
            }

            $bool->add($parsed, BoolQuery::SHOULD);
        }

        $bool->addParameter('minimum_should_match', '1');
        $search->addQuery($bool);
    }

    public function addSortings(EntityDefinition $definition, Criteria $criteria, Search $search, Context $context): void
    {


                    continue;
                }

                $result->addWhere(
                    sprintf('IF(%s , %s, 0)', $where(string) $this->connection->quote($query->getScore()))
                );
            }

            foreach ($parsed->getParameters() as $key => $parameter) {
                $result->addParameter($key$parameter$parsed->getType($key));
            }
        }

        return $result;
    }

    public function parse(
        Filter $query,
        EntityDefinition $definition,
        Context $context,
        ?string $root = null,
        
Home | Imprint | This part of the site doesn't use cookies.