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"
BooleanValue
true
false
Integer
/-?([1-9][0-9]+|[0-9])/
Digits
/[0-9]+/
Exponent
/[eE][+-]?[0-9]+/
LineTerminator
New Line (U+000A)
Carriage Return (U+000D)New Line (U+000A)
EscapedUnicode
/[0-9A-Fa-f]{4}/
EscapedCharacter
"\/bfnrt
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)
IsEmpty
Identifierisnotoptempty
IsDefined
Identifierisnotoptdefined

§Index

  1. AndExpression
  2. AnyValue
  3. AnyValues
  4. BooleanValue
  5. Comparison
  6. ComparisonOperator
  7. ComparisonValue
  8. ConditionalExpression
  9. ContainsAll
  10. ContainsAny
  11. Digits
  12. EmbeddedExpression
  13. EscapedCharacter
  14. EscapedUnicode
  15. Exponent
  16. Fraction
  17. Identifier
  18. InExpression
  19. InputParameter
  20. Integer
  21. IsDefined
  22. IsEmpty
  23. LineTerminator
  24. ListOfNumbers
  25. ListOfValues
  26. MatchesIgnoreCase
  27. NegateExpression
  28. NumberValue
  29. NumberValues
  30. OrExpression
  31. PrimitiveValue
  32. QueryPredicateExpression
  33. SimpleExpression
  34. SourceCharacter
  35. StringCharacter
  36. StringValue
  37. WhiteSpace
  38. WithinCircleCoordRadius
  1. 1Language Grammar
    1. 1.1White Space
    2. 1.2Identifiers
    3. 1.3Primitive Values
    4. 1.4Query Predicate
      1. 1.4.1Logical Operators
      2. 1.4.2Conditional Expressions
        1. 1.4.2.1Comparison
        2. 1.4.2.2Simple Expressions
  2. §Index