The following is a formal definition of the RQL grammar:
RQLStatement:: Query OrderByClause RangeClause
Query:: OR | AND | NOT | Comparison | ID IN | IN FOLDERS | ALL |
TextSearch | PropertyTextSearch | INCLUDES ITEM | IS NULL | (Query)
The precedence order of the queries from highest to lowest is as follows:
(Query)
Comparison, ID IN, IN FOLDERS, ALL, TextSearch, PropertyTextSearch, INCLUDES ITEM, IS NULL
NOT
AND
OR
OR:: Query OR Query ...
AND:: Query AND Query ...
NOT:: NOT Query
Comparison:: Expression ComparisonOperator Expression
ComparisonOperator:: = | != | < | <= | > | >= | INCLUDES ANY | INCLUDES ALL | INCLUDES | STARTS WITH [IGNORECASE] | ENDS WITH [IGNORECASE] | CONTAINS [IGNORECASE]
IdIn:: ID IN StringArray
InFolders:: IN FOLDERS StringArray
All:: ALL
TextSearch:: MATCH StringLiteral [USING StringLiteral]
PropertyTextSearch:: ObjectExpression MATCHES StringLiteral [USING StringLiteral]
IncludesItem:: Expression INCLUDES ITEM ( Query )
Expression:: CountExpression | ObjectExpression | ParameterExpression | ConstantExpression
CountExpression:: COUNT ( ObjectExpression | ParameterExpression | ConstantExpression )
ObjectExpression:: PropertyName | ObjectExpression.PropertyName | ObjectExpression[Expression]
PropertyName:: <Java identifier>
ParameterExpression:: ?<Parameter number>[.<Field name>]
ConstantExpression:: StringLiteral | IntegerLiteral | DoubleLiteral | BooleanLiteral | ArrayLiteral
StringLiteral:: “<Java string literal>“
The string literal uses the Java format, including escape characters (including octal and Unicode), and must be enclosed in double quotes.
IntegerLiteral:: <Java integer literal>
DoubleLiteral:: <Java double literal>
BooleanLiteral:: true | false
ArrayLiteral:: { ConstantExpression, ... }
StringArray:: { StringLiteral, ... }
OrderByClause:: ORDER BY PropertyName [[SORT] [ ASC | DESC]] [CASE [ IGNORECASE | USECASE]]
The SORT ASC/DESC directives are optional and default to SORT ASC. The CASE IGNORECASE/USECASE directives are optional and default to CASE USECASE.
RangeClause:: RANGE <Starting Index> + <Count>