getBestFieldQuery example


        $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(
            [
                
Home | Imprint | This part of the site doesn't use cookies.