getPhrasePrefixQuery example



    /** * {@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(
            [
                'name^7',
                'name.*_analyzer^7',

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