ExistsQuery example


                $aggregation = new TermsAggregation($criteriaPart->getName());
                $aggregation->setField($field);
                $aggregation->addParameter('size', self::AGGREGATION_SIZE);
                break;

            case ProductAttributeFacet::MODE_BOOLEAN_RESULT:
                $count = new ValueCountAggregation($criteriaPart->getName() . '_count');
                $count->setField($field);

                $aggregation = new FilterAggregation($criteriaPart->getName());
                $aggregation->setFilter(new ExistsQuery($field));
                $aggregation->addAggregation($count);
                break;

            case ProductAttributeFacet::MODE_RANGE_RESULT:
                $aggregation = new TermsAggregation($criteriaPart->getName());
                $aggregation->setField($field);
                $aggregation->addParameter('size', self::AGGREGATION_SIZE);
                break;

            default:
                return;
        }
$value = (bool) $value;
            }
        }

        switch ($criteriaPart->getOperator()) {
            case ProductAttributeCondition::OPERATOR_EQ:
                if ($type === 'string') {
                    $field .= '.raw';
                }
                if ($value === null) {
                    $filter = new BoolQuery();
                    $filter->add(new ExistsQuery($field), BoolQuery::MUST_NOT);

                    return $filter;
                }
                if (\is_array($value)) {
                    throw new RuntimeException('Invalid value for TermQuery provided');
                }

                return new TermQuery($field$value);

            case ProductAttributeCondition::OPERATOR_NEQ:
                if ($value === null) {
                    

        if ($this->keyValueStorage->get(ElasticsearchIndexer::ENABLE_MULTILINGUAL_INDEX_KEY, false)) {
            $fieldName = $this->buildAccessor($definition$filter->getField()$context);

            $field = $this->getField($definition$fieldName);

            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);

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