Doradus Query Language (DQL) : Quantifier Functions : Quantifiers on Group Fields

Quantifiers on Group Fields
Doradus Spider allows quantifiers (ANY, ALL, and NONE) on group fields. Group field quantification works as follows: Assume a group field G with leaf fields F1, F2, … Fn. Quantifiers can be used on the group field G if all fields Fi are of the same type:
When a group field is quantified, the quantifier is applied to the union of the leaf field values. That is, the quantifier Q on the group field G:
Q(G)
This is interpreted as:
Q(union(F1, F2, ..., Fn))
In our example Msgs schema, the Message table’s group field Participants contains three links that all refer to the Participant table: ExternalRecipients, InternalRecipients, and Sender. Consider the following query:
ANY(Participants.ReceiptDate) = [2013-01-01 TO 2013-01-31]
This is evaluated as the following equivalent expression:
ANY(union(ExternalRecipients, InternalRecipients, Sender).ReceiptDate) = [2013-01-01 TO 2013-01-31]
The “union” function does not actually exist – it is shown for illustrative purposes. It semantically combines all link values into a single set. If any linked object has a ReceiptDate within the given range, the entire expression is true. The ANY quantifier is false when all three links are null since ANY on an empty set is false.
If ALL is used instead of ANY, the overall expression is true only if all values in the set have a ReceiptDate within the given range and the set is not empty.
If NONE is used, the overall expression is true if none of the objects in the set have a ReceiptDate within the given range or if the set is empty. Unlike ANY and ALL, NONE quantification returns true if the set is empty.
Quantifiers can also be used on group fields whose leaf fields are scalars of the same type. In the example schema, the Person table’s Location field is a group containing the scalar text fields Department and Office. The following query:
GET /Msgs/Person/_query?q=NONE(Location):Sales
Finds people for which neither Department nor Office contains the term Sales.