/** * {@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'); } }
/** * Negates an expression for the current field. * * @see Builder::not() * @see http://docs.mongodb.org/manual/reference/operator/not/ * @param array|Expr $expression * @return $this */ public function not($expression) { return $this->operator('$not', $expression instanceof Expr ? $expression->getQuery() : $expression); }
/** * 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); }
/** * Add $within criteria with a $centerSphere shape to the query. * * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin * @see Builder::geoWithinCenterSphere() * @see Expr::withinCenterSphere() * @see http://docs.mongodb.org/manual/reference/operator/centerSphere/ * @param float $x * @param float $y * @param float $radius * @return self */ public function withinCenterSphere($x, $y, $radius) { $this->expr->withinCenterSphere($x, $y, $radius); return $this; }
/** * Specify $type criteria for the current field. * * @see Expr::type() * @see http://docs.mongodb.org/manual/reference/operator/type/ * @param integer $type * @return $this */ public function type($type) { $this->query->type($type); return $this; }
/** * @expectedException InvalidArgumentException */ public function testWithinPolygonRequiresAtLeastThreePoints() { $expr = new Expr(); $expr->withinPolygon(array(0, 0), array(1, 1)); }
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(); }
/** * Add $within criteria with a $polygon shape to the query. * * Point coordinates are in x, y order (easting, northing for projected * coordinates, longitude, latitude for geographic coordinates). * * The last point coordinate is implicitly connected with the first. * * @deprecated 1.1 MongoDB 2.4 deprecated $within in favor of $geoWithin * @see Builder::geoWithinPolygon() * @see Expr::withinPolygon() * @see http://docs.mongodb.org/manual/reference/operator/polygon/ * @param array $point,... Three or more point coordinate tuples * @return $this */ public function withinPolygon() { $this->expr->withinPolygon(...func_get_args()); return $this; }
/** * @expectedException InvalidArgumentException */ public function testWithinPolygonRequiresAtLeastThreePoints() { $expr = new Expr(); $expr->withinPolygon([0, 0], [1, 1]); }