Commercetools Query Predicate Spec
1Language Grammar
This document describes the predicate language syntax for querying resources in the commercetools platform. This predicate syntax is used with the where
query parameter or GraphQL field argument.
All language keywords are case insensitive.
1.1White Space
WhiteSpace
Form Feed (U+000C)
Line Feed (U+000A)
Carriage Return (U+000D)
Horizontal Tab (U+0009)
Space (U+0020)
1.2Identifiers
Identifier
/[-_A-Za-z0-9]+/
1.3Primitive Values
These language syntax rules define basic partitive values like string or number.
An example of number literal
Example № 1123.045e-10
And this is an example or string literal
Example № 2"An example \u00F0\u009F\u0091\u008D string\n"
Integer
/-?([1-9][0-9]+|[0-9])/
Digits
/[0-9]+/
Exponent
/[eE][+-]?[0-9]+/
EscapedUnicode
/[0-9A-Fa-f]{4}/
EscapedCharacter
" | \ | / | b | f | n | r | t |
SourceCharacter
/[\u0009\u000A\u000D\u0020-\uFFFF]/
1.4Query Predicate
1.4.1Logical Operators
Basic logical operators. An example:
Example № 3[some expression] and ([some expression] or not [some expression])
1.4.2Conditional Expressions
In addition to simple field comparison, the language also defines embedded expressions that define a nested predicate:
Example № 4variant(sku = "TEST")
1.4.2.1Comparison
Basic comparison operators. An example simple comparison expression:
Example № 5centAmount > 1500
The language also defines input parameters to parameterize the query predicate:
Example № 6centAmount > :minPrice and centAmount <= :maxPrice
ComparisonOperator
= | <> | != | >= | > | <= | < |
1.4.2.2Simple Expressions
Some examples:
Example № 7sku contains all ("foo", "bar")
location within circle (13.37770, 52.51627, 5)
§Index
- AndExpression
- AnyValue
- AnyValues
- BooleanValue
- Comparison
- ComparisonOperator
- ComparisonValue
- ConditionalExpression
- ContainsAll
- ContainsAny
- Digits
- EmbeddedExpression
- EscapedCharacter
- EscapedUnicode
- Exponent
- Fraction
- Identifier
- InExpression
- InputParameter
- Integer
- IsDefined
- IsEmpty
- LineTerminator
- ListOfNumbers
- ListOfValues
- MatchesIgnoreCase
- NegateExpression
- NumberValue
- NumberValues
- OrExpression
- PrimitiveValue
- QueryPredicateExpression
- SimpleExpression
- SourceCharacter
- StringCharacter
- StringValue
- WhiteSpace
- WithinCircleCoordRadius