public function testOperatorWithCurrentField() { $expr = new Expr(); $expr->field('field'); $this->assertSame($expr, $expr->operator('$op', 'value')); $this->assertEquals(array('field' => array('$op' => 'value')), $expr->getQuery()); }
/** * {@inheritdoc} */ public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = []) { if (Operators::IS_EMPTY !== $operator) { $this->checkValue($field, $value); if (FieldFilterHelper::getProperty($field) === FieldFilterHelper::CODE_PROPERTY) { $value = $this->objectIdResolver->getIdsFromCodes('family', $value); } } $fieldCode = FieldFilterHelper::getCode($field); switch ($operator) { case Operators::IN_LIST: $expr = new Expr(); $this->qb->addAnd($expr->field($fieldCode)->in($value)); break; case Operators::NOT_IN_LIST: $this->qb->field($fieldCode)->notIn($value); break; case Operators::IS_EMPTY: $exists = new Expr(); $equals = new Expr(); $expr = new Expr(); $exists->field($fieldCode)->exists(false); $equals->field($fieldCode)->equals(null); $expr->addOr($exists)->addOr($equals); $this->qb->addAnd($expr); break; } return $this; }
/** * {@inheritdoc} */ public function addAttributeFilter(AbstractAttribute $attribute, $operator, $value) { $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $this->context); $field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, $field); $field = sprintf('%s.id', $field); if (in_array('empty', $value)) { unset($value[array_search('empty', $value)]); $expr = new Expr(); $expr = $expr->field($field)->exists(false); $this->qb->addOr($expr); } if (count($value) > 0) { $value = array_map('intval', $value); $expr = new Expr(); $expr->field($field)->in($value); $this->qb->addOr($expr); } return $this; }
/** * {@inheritdoc} */ public function addFieldFilter($field, $operator, $value) { $value = is_array($value) ? $value : [$value]; if ($operator === 'NOT IN') { $this->qb->field($field)->notIn($value); } else { if (in_array('empty', $value)) { unset($value[array_search('empty', $value)]); $expr = new Expr(); $expr = $expr->field($field)->exists(false); $this->qb->addOr($expr); } if (count($value) > 0) { $expr = new Expr(); $expr->field($field)->in($value); $this->qb->addOr($expr); } } return $this; }
private function buildQueryForValueDescription(ValueDescription $valueDescription, Expr $expr, PropertyId $currentProperty = null) { $value = $valueDescription->getValue(); switch ($valueDescription->getComparator()) { case ValueDescription::COMP_EQUAL: case ValueDescription::COMP_LIKE: $expr->field('sclaims.' . $value->getType())->equals($this->buildPropertyValueForSearch($currentProperty, $value)); return $expr; default: throw new FeatureNotSupportedException('Unsupported ValueDescription comparator'); } }
/** * Apply the query part to search for product where the completenesses * are missing. Apply only to the channel or product if provided. * * @param Builder $productsQb * @param ProductInterface $product * @param ChannelInterface $channel */ protected function applyFindMissingQuery(Builder $productsQb, ProductInterface $product = null, ChannelInterface $channel = null) { if (null !== $product) { $productsQb->field('_id')->equals($product->getId()); } else { $combinations = $this->getChannelLocaleCombinations($channel); if (!empty($combinations)) { foreach ($combinations as $combination) { $expr = new Expr(); $expr->field('normalizedData.completenesses.' . $combination)->exists(false); $productsQb->addOr($expr); } } } $productsQb->field('family')->notEqual(null); }
/** * Set the current field for building the expression. * * @see Expr::field() * @param string $field * @return self */ public function field($field) { $this->expr->field((string) $field); return $this; }
private function buildGetEntitiesForIdsQuery(array $entityIds) { $expr = new Expr(); return $expr->field('_id')->in($this->serializeEntityIds($entityIds))->getQuery(); }
private function buildGetEntityIdForTermQuery(Term $term) { $expr = new Expr(); $expr->field('sterms.' . $term->getLanguageCode())->equals($this->documentBuilder->cleanTextForSearch($term->getText())); return $expr->getQuery(); }