getScoreField example

EntityDefinition $definition,
        string $root,
        Context $context
    ): ParseResult {
        $result = new ParseResult();

        /** @var ScoreQuery $query */
        foreach ($queries as $query) {
            $parsed = $this->parse($query->getQuery()$definition$context$root);

            foreach ($parsed->getWheres() as $where) {
                if ($query->getScoreField()) {
                    $field = $this->queryHelper->getFieldAccessor(
                        $query->getScoreField(),
                        $definition,
                        $root,
                        $context
                    );

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

                    
unset($sort['direction']);
            }
            unset($sort);
        }

        if (\count($criteria->getQueries())) {
            $array['query'] = [];

            foreach ($criteria->getQueries() as $query) {
                $arrayQuery = [
                    'score' => $query->getScore(),
                    'scoreField' => $query->getScoreField(),
                    'extensions' => $query->getExtensions(),
                ];
                $arrayQuery['query'] = QueryStringParser::toArray($query->getQuery());
                $array['query'][] = $arrayQuery;
            }
        }

        if (\count($criteria->getGroupFields())) {
            $array['grouping'] = [];

            foreach ($criteria->getGroupFields() as $groupField) {
                
Home | Imprint | This part of the site doesn't use cookies.