EQL (Easy Query Language)  by example

Reserved words

current, now, sec(s), min(s), hour(s), day(s), today, week(s), month(s), year(s), tomorrow, yesterday, last, next, undef, #pragma, me

Operators

and, or, &&, ||, :, <, >, >:, <:, !:, :~

Identifiers

sequence of letters and digits. First character should be a letter. Dots (.) are also accepted in the identifier body.

Literals

 

Syntax

General Syntax

 

The EQL tries to come with a simpler yet powerful alternative to AQL syntax. While AQL is more an application developer tool, EQL targets mainly the end-user group.

 

The basic EQL construct, the condition, follows the regular pattern found in most query languages:

 <attributeName> <operator> <literal>

such as:

tag:java

created >: yesterday

Conditions may be aggregated using the AND, OR and parentheses:

project : aq  AND  ( age  >  20  OR  experience : true )

The implicit aggregation operator is AND and therefore following EQL statements are equivalent :

aType:comment  tag:java

~ is equivalent with ~

aType:comment AND tag:java

Full text search

EQL provides a simplified condition syntax for the full text search capability. The simplest   statement in EQL is one word, e.g. :

 

java

The above statement is performing a full text search on all attributes for all entities in the data cluster. Alternatively, for phrase matches or to simply mask not allowed characters we may supply the word sequence as (quoted) string literal:

 

'java tutorial'

 

EQL is treating several words as conditions aggregated with AND operator. For instance following EQL:

 

java 'hello world'

 

~ is equivalent with ~

 

java AND 'hello world'

Date handling

Attributes which are storing dates as number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT can be filtered using special, built-in tokens:

The generic date syntax is :

today

tomorrow

yesterday

current

last

next

and followed by an optional integer an one of the following tokens:

sec(s)

min(s)

hour(s)

day(s)

week(s)

month(s)

year(s)

For instance filtering all objects created today may be accomplished by using the following condition:

... and created : today

or alternatively objects NOT created last year may be returned by:

... and created  !:  last year

If the prefix is omitted the 'current' prefix is assumed

... created : current week  ~  ... created : week

When using other operators (<, >, <:, :>) with date expressions, the start of the specific time range is considered in the evaluation.

For instance,

... created > last week

will return objects created starting with the first millisecond of the last week.

To filter entities created two weeks ago (only during this specific week), for the sake of language modularization, we currently pay a price in terms of statement intuitiveness :

... created : last 2 week(s)

while filtering entities created in the last two weeks,  the expression is:

... created > last 2 week(s)

 UNDEF meta-attribute

   

EQL contains the special keyword 'undef', which can be used to filter any of the objects attributes. The following example might return, for instance, objects having tag='java' as well as objects having language = 'java':

 

 

'hello world' undef:java  

  Wildcards

  AQL offers following (OS like) wildcards :

*  -   matches any sequence of characters

?  -  matches only one character

which can be used only in conjunction with 'like' operator:

... undef  :~  'jav*'

The wildcards can be escaped in string literals using the backslash ('\') in case the filter has to match the '*' or '?' characters explicitly:

... undef :~ '\*jav*'

  Limitations in EQL

  

In contrast to AQL, EQL is not having an IN construct. The same for condition aggregation using parentheses: currently only explicit conditions may be combined using AND or OR operators.

  

   'hello world' ( tag:java or tag:lisp )

  QUALITY attribute

  

An interesting construct trying to simplify the language syntax and enhance its usability is the  named filter or the 'quality' attribute. A 'quality'  is an EQL statement previously stored in the data cluster which can be invoked in subsequent EQL statements. One can use the regular condition syntax:

   

   'hello world' quality:demoQuality

  

  

  or the shortcut notation:

'hello world' @demoQuality

  

Qualities have to be persisted on the cluster prior to their invocation. The sample 'quality' object stored on the data cluster and invoked in the above examples looks like:

        class = aq.internal.Shortcut

domain = 'aspectweb.org'

        name = demoQuality

        description = 'Some decent description relevant when looking for qualities'

        value = 'tag:search created: current year creator:me'

  

 Thus, the EQL statement

'hello world' @demoQuality

~ is equivalent with ~

'hello world'  tag:search created: current year

Another obvious advantage beyond the syntax simplicity is the hiding of unnecessary complexity to the end-user.

  Cache instructions

Current EQL syntax allows also instructions on expected result actuality. Depending on what 'actual' may represent from application or user perspective, the query response time may be drastically improved by leveraging the cluster cache. The rule of thumb is that lower expectations reward with better performance. Achieved by adding cache expire rules (time in sec):

 #pragma{cache:'100'}

as statement prefix:

#pragma{cache:'300'} 'hello world' ( tag:java or tag:lisp )

 The 'me' alias

Current logged-on user can be aliased in EQL statements using the 'me' keyword. This is not only a very handy notation for complex user identifiers (such fingerprints) but tremendously useful to provide re-usability/portability for named filters (a.k.a. stored queries):

 creator: me

~ can be equivalent with ~

creator: 'd7a8cdfe-ae78-40d7-9103-24c0a2061718'

Putting all together examples

class:'org.aq.Annotation' atype:warning domain:'wikipedia.org'  

class:'org.aq.Annotation' created:yesterday creator:'myOpenId' tag:'web3.0'