OLAP Object Queries : Fields Parameter : Link Field AS Aliases

Link Field AS Aliases
By default, when an object query returns link fields, the link field name and filter, if present, are used in the query result. For example, in the following parameter:
.../_query?f=InternalRecipients.WHERE(Person.LastName:wright)&q=...
The query results identifies the values belonging to the InternalRecipients link as follows:
<doc>
<field name="_ID">D+EGzQxdH1jWk9CCZqts1Q==</field>
<field name="_shard">s1</field>
<field name="InternalRecipients.WHERE(Person.LastName:wright)">
<doc>
<field name="_ID">w1snUDxw3pZHh5yr55oHBA==</field>
</doc>
</field>
</doc>
The expanded link field name can be simplified by using the AS function, as shown below:
.../_query?f=InternalRecipients.WHERE(Person.LastName:wright).AS(Wright)&q=...
The AS function must appear after the WHERE filter and/or link size limit, if any. The parameter to the AS function can be an unquoted term or a quoted string. The parameter value defines a field name alias that is used instead of the default link field name in the query results. For example:
<doc>
<field name="_ID">D+EGzQxdH1jWk9CCZqts1Q==</field>
<field name="_shard">s1</field>
<field name="Wright">
<doc>
<field name="_ID">w1snUDxw3pZHh5yr55oHBA==</field>
</doc>
</field>
</doc>
Multiple AS functions can be used in the same object query. However, alias names used at the same level must be unique so that each field name in the output results is unique.
The AS function can be useful to identify query results when table-level alias is used. For example, assume the following alias definition:
"Person": {
aliases: {
"$SalesPeople": {"expression": "WHERE(Department:sales)"}
}
...
}
The alias $SalesPeople can be used as in a fields parameter, potentially with additional filtering, as in the following example:
GET /Email/Message/_query?q=Size>100000&range=0
&f=Sender.Person.
$SalesPeople.WHERE(Office:aliso).LastName
By default, the query results for the Person link includes the filters in both the alias definition and the &f parameter. For example, it will appear within the Sender group element as follows:
<field name="Sender">
<doc>
<field name="_ID">Klk8VEzG2ZBQMLibi/t4Ig==</field>
<field name="Person.WHERE((Department:sales) AND (Office:aliso))">
<doc>
<field name="LastName">McKeehan</field>
<field name="_ID">tNI90WCArcnd76jEeEWmxg==</field>
</doc>
</field>
</doc>
</field>
The AS function can apply an alias that makes the link element easier to identify. So, for example:
GET /Email/Message/_query?q=Size>100000&range=0
&f=Sender.Person.
$SalesPeople.WHERE(Office:aliso).AS("Sales Person").LastName
This causes the results to appear as follows:
<field name="Sender">
<doc>
<field name="_ID">Klk8VEzG2ZBQMLibi/t4Ig==</field>
<field name="Sales Person">
<doc>
<field name="LastName">McKeehan</field>
<field name="_ID">tNI90WCArcnd76jEeEWmxg==</field>
</doc>
</field>
</doc>
</field>