createNestedQuery example

if ($filter->getValue() === null) {
                $query = new BoolQuery();

                if ($field instanceof TranslatedField) {
                    foreach ($context->getLanguageIdChain() as $languageId) {
                        $query->add(new ExistsQuery(sprintf('%s.%s', $fieldName$languageId)), BoolQuery::MUST_NOT);
                    }
                } else {
                    $query->add(new ExistsQuery($fieldName), BoolQuery::MUST_NOT);
                }

                return $this->createNestedQuery($query$definition$filter->getField());
            }

            $value = $this->parseValue($definition$filter$filter->getValue());
            $query = new TermQuery($fieldName$value);

            if ($field instanceof TranslatedField) {
                $multiMatchFields = [];

                foreach ($context->getLanguageIdChain() as $languageId) {
                    $multiMatchFields[] = $this->getTranslatedFieldName($fieldName$languageId);
                }

                
private function resolveSubJoin(JoinGroup $group, EntityDefinition $definition, QueryBuilder $query, Context $context): void
    {
        $fields = EntityDefinitionQueryHelper::getFieldsOfAccessor($definition$group->getPath(), false);

        $first = array_shift($fields);

        if (!$first instanceof AssociationField) {
            throw new \RuntimeException('Expect association field in first level of join group');
        }

        $nested = $this->createNestedQuery($first$definition$context);

        foreach ($group->getFields() as $accessor) {
            if ($accessor === '_score') {
                continue;
            }
            $this->resolveField($group$accessor$definition$nested$context);
        }

        $alias = $definition->getEntityName() . '.' . $first->getPropertyName() . $group->getSuffix();

        $this->parseFilter($group$definition$nested$context$alias);

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