Filtering
The WHERE condition is shared among many SQL commands.
A condition results in a boolean; and a compound condition,
consisting of multiple conditions that are combined with logical operators,
is resolved from left to right.
Syntax
[<item>] <operator> <item>
Items
And item can be:
| What | Description | Example |
|---|---|---|
field |
Document field |
|
field<indexes> |
Document field part. To know more about field part look at the full syntax: Document-API-Property |
|
record attribute |
Record attribute name with |
|
Any Function between the defined ones |
|
|
|
Context variable prefixed with |
|
Record attributes
| Name | Description | Example |
|---|---|---|
|
returns the record itself |
|
|
returns the RID in the form |
|
|
returns the record size in bytes |
|
|
returns the record type between: 'document', 'column', 'flat', 'bytes' |
|
Operators
Conditional Operators
| Apply to | Operator | Description | Example |
|---|---|---|---|
any |
|
Equals |
|
any |
|
Null-safe-equals, is also true if left and right operands are |
|
string |
|
Similar to equals, but allows the wildcards ‘%’ that means "any characters" and ‘?’ that means "any single character". |
|
string |
|
Similar to |
|
string |
|
Negation of |
|
string |
|
Negation of |
|
any |
|
Less than |
|
any |
|
Less or equal to |
|
any |
|
Greater than |
|
any |
|
Greater or equal to |
|
any |
|
Not equal to |
|
any |
|
The value is between a range. It’s equivalent to |
|
any |
|
Used to test if a value is |
|
any |
|
Used to test if a value is not |
|
record, string (as type name) |
|
Used to check if the record extends a type |
|
collection |
|
contains any of the elements listed. Uses the index on the property, including the leading columns of a composite index ( |
|
collection |
|
contains all of the elements not listed. Does not use index: an index can look up the listed values, not their complement, so the type is scanned. If the type is large, add a second indexed condition to the query to drive the lookup |
|
collection |
|
true if the collection contains at least one element that satisfy the next condition. Use |
|
collection |
|
true if every element of the right collection is contained in the left collection |
|
collection |
|
true if at least one element of the right collection is contained in the left collection |
|
map |
|
true if the map contains at least one key equals to the requested. You can also use |
|
map |
|
true if the map contains at least one value equals to the requested. You can also use |
|
string |
|
When used against an indexed field, a lookup in the index will be performed with the text specified as key. When there is no index a simple Java |
|
string |
|
Matches the string using a Regular Expression. Use the modifier |
|
LIKE, ILIKE, MATCHES are not using full-text indexes.
|
CONTAINS asks whether the collection on the left holds a single value: either one matching the condition,
or, when the right side is a plain value, one equal to it. Put a collection on the right and it is searched for as one
element, so tags CONTAINS ['red','blue'] matches a row whose tags holds the nested list ['red','blue'], and
not a row whose tags is ['red','green','blue']. To compare two collections, use CONTAINSALL (every element
of the right is present on the left) or CONTAINSANY (at least one is). This applies equally when the right side is
produced by an expression such as 'red blue'.split(' ').
|
Logical Operators
| Operator | Description | Example |
|---|---|---|
AND |
true if both the conditions are true |
|
OR |
true if at least one of the condition is true |
|
NOT |
true if the condition is false. |
|
Mathematics Operators
| Apply to | Operator | Description | Example |
|---|---|---|---|
Numbers |
+ |
Plus |
|
Numbers |
- |
Minus |
|
Numbers |
* |
Multiply |
|
Numbers |
/ |
Divide |
|
Numbers |
% |
Mod |
|
Methods
Also called "Field Operators", are SQL-Methods.
Variables
ArcadeDB supports variables managed in the context of the command/query. By default, some variables are created. Below the table with the available variables:
| Name | Description | Command(s) |
|---|---|---|
|
Get the parent context from a sub-query. Example: |
|
|
Current record to use in sub-queries to refer from the parent’s variable |
|
|
The current depth of nesting |
|
|
The string representation of the current path. Example: |
|
|
The List of operation in the stack. Use it to access to the history of the traversal |
|
|
The set of all the records traversed as a |
To set custom variable use the LET keyword.
Wildcards
| Symbol | Description | Example |
|---|---|---|
|
Matches all strings that contain an unknown substring of any length at the position of |
"%DB" "A%DB" "Arcade%" all match "ArcadeDB" |
|
Matches all strings that contain an unknown character at the position of |
"N?SQL" matches "NoSQL" but not "NewSQL" |
Filtering for strings containing wildcards characters can be done by escaping with backslash, i.e. \%, \?.