Using EQL results to compose follow-on queries

You can select a value in an EQL result and use it to compose a follow-on query.

This enables users to interact with EQL results through a chart or a graph to compose follow-on queries. For example, when viewing a chart of year-to-date sales by country, a user might select a specific country for drill-down.

EQL is specifically designed to support this kind of follow-on query.

If, in the above example, the user selects the country United States, then the follow-on query should examine only sales of products in the United States. To filter to these items, a WHERE clause like the following can be added:

WHERE DimGeography_CountryRegionName = 'United States'

For attributes with types other than string, a conversion is necessary to use the string representation of the value returned by EQL. For an integer attribute, such as DimDate_CalendarYear, the string representation of the value must be converted to an integer for filtering, as follows:

WHERE DimDate_CalendarYear = TO_INTEGER('2006').
EQL provides conversions for all non-string data types:
  • TO_BOOLEAN()
  • TO_DATETIME()
  • TO_DOUBLE()
  • TO_DURATION()
  • TO_GEOCODE()
  • TO_INTEGER()
  • TO_TIME()

Each of these accepts the string representation of values produced by the Dgraph. Note that no conversion is necessary for mdex:string attributes.

To determine which conversion function to use, EQL results are accompanied by attribute metadata that describes the type of the attribute.