An FQL query must return a result indicated by usage either of the
FOR IN or
FOR WHILE keywords. The FQL parser will return an error if it cannot find any of these two statements.
Multi-line comments cannot be nested, which means subsequent comment starts within comments are ignored, comment ends will end the comment.
FQL supports two types of comments:
- Single line comments: These start with a double forward slash and end at the end of the line, or the end of the query string (whichever is first).
- Multi line comments: These start with a forward slash and asterisk, and end with an asterisk and a following forward slash. They can span as many lines as necessary.
USE: allows the use of types in a namespace without typing full type path.
FOR: iteration over a data source or logical condition
RETURN: results projection
FILTER: non-view results filtering
SEARCH: view results filtering
SORT: result sorting
LIMIT: result slicing
LET: variable assignment
COLLECT: result grouping
Each of the above operations can be initiated in a query by using a keyword of the same name. An FQL query can (and typically does) consist of multiple of the above operations.
An example FQL query may look like this:
In this example query, the terms
RETURN initiate the higher-level operation according to their name. These terms are also keywords, meaning that they have a special meaning in the language.
For example, the query parser will use the keywords to find out which high-level operations to execute. That also means keywords can only be used at certain locations in a query. This also makes all keywords reserved words that must not be used for other purposes than they are intended for.
At this moment, keywords are not case-insensitive, meaning they cannot be specified in lower or mixed case in queries.
There are a few more keywords in addition to the higher-level operation keywords. Additional keywords may be added in future versions of Ferret. The complete list of keywords is currently:
The maximum supported length of any name is 64 bytes. Names in FQL are always case-sensitive.
Keywords must not be used as names. If a reserved keyword should be used as a name, the name must be enclosed in single or double quotes. Enclosing a name in quotes makes it possible to use otherwise reserved keywords as names. An example for this is:
Allowed characters in variable names are the letters a to z (both in lower and upper case), the numbers 0 to 9, the underscore (_) symbol and the dollar ($) sign. A variable name must not start with a number. If a variable name starts with the underscore character, the underscore must be followed by least one letter (a-z or A-Z) or digit (0-9).