What is the recommended approach for complex where clauses in AQL?
Ryan pointed out two approaches:
1) encode OR using the typeside.
2) encode OR using the union (sum) of many queries.
'and' logic is pretty simple but 'or' is more involved.
from source as s
where s.channel = 5 and s.type = 'a-n-A-C-F-m'
query q_and = simple : S2 {
from
s : Source
where
s.channel = 5
s.type = "a-n-A-C-F-m"
return
}
Setting aside the problem that only the equality relational operator is supported
the following example illustrates disjunction using the (1) typeside approach.
from source as s
where s.channel = 5 or s.type = 'a-n-A-C-F-m'
query q_and = simple : S2 {
from
s : Source
where
or(eqInt(s.channel,5), eqVc(ce.cot_type,"a-n-A-C-F-m")) = true
return
}
The or is dealt with here using java_functions.
java_functions
eqVc : VARCHAR, VARCHAR -> BOOLEAN = "return input[0].equals(input[1])"
eqInt : INTEGER, INTEGER -> BOOLEAN = "return input[0] == input[1]"
or : BOOLEAN, BOOLEAN -> BOOLEAN = "return input[0] || input[1]"
The typeside approach can be used to handle the lack of relational operators.
How is the (2) summation approach done in AQL?