FROM clauses

You can include a FROM clause in your statement to specify a different record source from the result of the containing search and navigation query.

By default, the source of records for an EQL statement is the result of the containing search and navigation query. However, you can also include the FROM syntax in your statement to specify a different data source, such as from a state name or from a previously-defined statement.

The FROM syntax is:

FROM <recSource> [alias]
where <recSource> can be:

If you omit the FROM clause in your query, the EQL statement uses the corpus-based NavStateRecords source.

Corpus-based source

Two names identify a corpus-based source:
  • AllBaseRecords: Every record that passed the security filter.
  • NavStateRecords: Every record that passed all previous filters.
For example:
FROM AllBaseRecords

The absence of FROM implies NavStateRecords. This means that if you want to submit your query against NavStateRecords, you do not need to include the FROM clause in your statement.

Previously-defined statement

You can use the result of a different statement as your record source. In the following example, a statement computes the total number of sales transactions for each quarter and sales representative. To then compute the average number of transactions per sales rep, a subsequent statement groups those results by quarter.
DEFINE RepQuarters AS
SELECT COUNT(TransId) AS NumTrans
GROUP BY SalesRep, Quarter;

RETURN Quarters AS
SELECT AVG(NumTrans) AS AvgTransPerRep
FROM RepQuarters
GROUP BY Quarter
The RepQuarters statement generates a list of records. Each record contains the attributes { SalesRep, Quarter, NumTrans }. For example:
{ J. Smith, 11Q1, 10 }
{ J. Smith, 11Q2, 3 }
{ F. Jackson, 10Q4, 10 }
...
The Quarters statement then uses the results of the RepQuarters statement to generate a list with the attributes { Quarter, AvgTransPerRep }. For example:
{ 10Q4, 10 }
{ 11Q1, 4.5 }
{ 11Q2, 6 }
...

State name

State names can be specified in EQL FROM clauses with this syntax:
FROM <statename>[.FILTERED | .UNFILTERED | .ALL]
where:
  • statename.FILTERED represents the state with all filters applied (i.e., all the filters that are in the state of the Conversation Service query).
  • statename (i.e., using just the state name without a filtering qualifier) is a synonym for statename.FILTERED.
  • statename.UNFILTERED represents the state with only the security filter applied (i.e., the DataSourceFilter if one exists in the state of the Conversation Service query).
  • statename.ALL is a synonym for statename.UNFILTERED.
As an example, assume this simple Conversation Service query that uses the EQLQuery type:
<Request>
   <Language>en</Language>
   <State>
      <Name>Wine</Name>
      <DataSourceFilter Id="DataFltr">
        <filterString>WineType <> 'Red'</filterString>
      </DataSourceFilter>
      <SelectionFilter Id="SecFltr">
        <filterString>Price > 25</filterString>
      </SelectionFilter>
   </State>
   <EQLConfig Id="Results">
      <StateName>Wine</StateName>
      <EQLQueryString>
        RETURN results AS
        SELECT Price AS prices
        FROM Wine.FILTERED
        GROUP BY prices
      </EQLQueryString>
   </EQLConfig>
</Request>
The query works as follows:
  1. The DataSourceFilter filter (which is the security filter) first removes any record that does not have a WineType=Red assignment. In our small data set, only 11 records pass the filter.
  2. The SelectionFilter filter then selects any record whose Price assignment is $25 or more. 7 more records are filtered out (from the previous 11 records), leaving 4 records.
  3. The FROM clause in the EQL statement references the state named Wine. Because FILTERED is used with the state name, both filters from the state are applied and the 4 records are returned. (The same behavior applies only if the state name is used.)
If, however, this FROM clause is used in the same query:
FROM Wine.UNFILTERED
then only the DataSourceFilter filter would be applied (i.e., the SelectionFilter filter would be ignored). In this case, the 11 records that passed the security filter would be returned by the EQL statement.