Doradus Query Language (DQL) : Link Clauses : Outer WHERE Filter

Outer WHERE Filter
The WHERE filter usually follows a link name to select related objects connected via that link. However, a link path can begin when a WHERE filter, in which case it selects perspective objects. For example:
GET /Email/Person/_query?q=WHERE(Department:sales)&range=0
This WHERE filter selects perspective objects, in this case Person. The query above is identical to the following:
GET /Email/Person/_query?q=Department:sales&range=0
The scope of an outer WHERE filter remains at the perspective object. Hence, multiple, outer WHERE filters can be chained together as in the following example:
GET /Email/Person/_query?q=WHERE(Department:sales).WHERE(Office:aliso)&range=0
The outer WHERE filters are AND-ed together, so the example above is identical to this query:
GET /Email/Person/_query?q=Department:sales AND Office:aliso&range=0
Outer WHERE filters allow aliases to be defined as link paths that can be used in multiple contexts. For example, assume the following alias is defined:
"Person": {
aliases: {
"$SalesPeople": {"expression": "WHERE(Department:sales)"}
}
...
}
The alias $SalesPeople can be used as a selection expression or link filter whenever the expression scope is Person. For example, the alias can be used in the following queries:
GET /Email/Person/_query?q=$SalesPeople&range=0
GET /Email/Person/_query?q=$SalesPeople.WHERE(Office:aliso)&range=0
GET /Email/Message/_query?q=Sender.Person.$SalesPeople&range=0
In the first two cases, the aliases expression WHERE(Department:sales) filters perspective Person objects. In the third case, the expression filters Person objects connected to a perspective Message object via Sender.Person.
Outer WHERE filters can also be used in aggregate query metric functions and grouping parameters (described elsewhere).