parseFilter example

$this->createMock(CustomFieldService::class),
            $storage
        );

        $context = new Context(
            new SystemSource(),
            [],
            Defaults::CURRENCY,
            [self::SECOND_LANGUAGE, Defaults::LANGUAGE_SYSTEM]
        );

        $esFilter = $parser->parseFilter($filter$definition, ProductDefinition::ENTITY_NAME, $context);
        static::assertSame($expectedEsFilter$esFilter->toArray());
    }

    public function testParseUnsupportedFilter(): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        static::expectException(\RuntimeException::class);
        static::expectExceptionMessage(sprintf('Unsupported filter %s', CustomFilter::class));
        $definition = $this->getDefinition();

        
$aggregation->setScript($script);

        return $this->addPostFilterAggregation($criteria$definition$context$aggregation);
    }

    private function addPostFilterAggregation(Criteria $criteria, EntityDefinition $definition, Context $context, CardinalityAggregation $aggregation): AbstractAggregation
    {
        if (!$criteria->getPostFilters()) {
            return $aggregation;
        }

        $query = $this->criteriaParser->parseFilter(
            new MultiFilter(MultiFilter::CONNECTION_AND, $criteria->getPostFilters()),
            $definition,
            $definition->getEntityName(),
            $context
        );

        $filterAgg = new FilterAggregation('total-filtered-count', $query);
        $filterAgg->addAggregation($aggregation);

        return $filterAgg;
    }
}
if ($nested === null) {
            throw new \RuntimeException(sprintf('Nested filter aggregation %s can not be parsed.', $aggregation->getName()));
        }

        // when aggregation inside the filter aggregation points to a nested object (e.g. product.properties.id) we have to add all filters         // which points to the same association to the same "nesting" level like the nested aggregation for this association         $path = $nested instanceof NestedAggregation ? $nested->getPath() : null;
        $bool = new BoolQuery();

        $filters = [];
        foreach ($aggregation->getFilter() as $filter) {
            $query = $this->parseFilter($filter$definition$definition->getEntityName()$context);

            if (!$query instanceof NestedQuery) {
                $filters[] = new Bucketing\FilterAggregation($aggregation->getName()$query);

                continue;
            }

            // same property path as the "real" aggregation             if ($query->getPath() === $path) {
                $bool->add($query->getQuery());

                
public function handleIds(EntityDefinition $definition, Criteria $criteria, Search $search, Context $context): void
    {
        $ids = $criteria->getIds();

        if (empty($ids)) {
            return;
        }

        /** @var list<string> $ids */
        $ids = array_values($ids);

        $query = $this->parser->parseFilter(
            new EqualsAnyFilter('id', $ids),
            $definition,
            $definition->getEntityName(),
            $context
        );

        $search->addQuery($query, BoolQuery::FILTER);
    }

    public function addFilters(EntityDefinition $definition, Criteria $criteria, Search $search, Context $context): void
    {
        
$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);

        $parameters = [
            '#root#' => self::escape($definition->getEntityName()),
            '#source_column#' => $this->getSourceColumn($first$context),
            '#alias#' => self::escape($alias),
        ];

        $query->leftJoin(
            self::escape($definition->getEntityName()),
            '(' . $nested->getSQL() . ')',
            self::escape($alias),
            
Home | Imprint | This part of the site doesn't use cookies.