getTerms example

/** * @dataProvider cases * * @param list<string> $expected */
    public function testMatching(string $term, array $expected): void
    {
        $context = Context::createDefaultContext();

        $matches = $this->interpreter->interpret($term$context);

        $keywords = array_map(fn (SearchTerm $term) => $term->getTerm()$matches->getTerms());

        sort($expected);
        sort($keywords);
        static::assertEquals($expected$keywords);
    }

    /** * @dataProvider casesWithTokenFilter * * @param list<string> $expected */
    
 else {
            $term = (string) $search;
        }

        $term = trim($term);
        if (empty($term)) {
            throw RoutingException::missingRequestParameter('search');
        }

        $pattern = $this->interpreter->interpret($term$context->getContext());

        foreach ($pattern->getTerms() as $searchTerm) {
            $criteria->addQuery(
                new ScoreQuery(
                    new EqualsFilter('product.searchKeywords.keyword', $searchTerm->getTerm()),
                    $searchTerm->getScore(),
                    'product.searchKeywords.ranking'
                )
            );
        }
        $criteria->addQuery(
            new ScoreQuery(
                new ContainsFilter('product.searchKeywords.keyword', $pattern->getOriginal()->getTerm()),
                


            $queries[] = new ScoreQuery(
                new ContainsFilter($select$term->getOriginal()->getTerm()),
                $ranking * $term->getOriginal()->getScore() * 0.5
            );

            if ($flag && !$flag->tokenize()) {
                continue;
            }

            foreach ($term->getTerms() as $part) {
                $queries[] = new ScoreQuery(
                    new EqualsFilter($select$part->getTerm()),
                    $ranking * $part->getScore()
                );

                $queries[] = new ScoreQuery(
                    new ContainsFilter($select$part->getTerm()),
                    $ranking * $part->getScore() * 0.5
                );
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.