Continuing with the franchise example, but considering only one store, we are planning to classify our customers by their buying frecuency, following the next table:
|Type of Customer||Condition|
|Compulsive Buyer||< 1 Hour|
|Regular Buyer||> 1 Hour and < 10 Hours|
|Lazy Buyer||> 10 Hours|
In this example we’ll be using the temporal operators after and before, and we`ll declare an attribute of the Sale Class as the timestamp of the event.
As you can see we have declared a new attribute in the Sale Class, date, and finally we declare it as a timestamp using the @timestamp METADATA. Below this declaration we have our rules set, these three rules are using the temporal operators that we have mentioned before.
Temporal Operators Considerations:
We can optionally set a temporal distance interval (TDI) in the after operator or in the before operator:
$saleA : Sale( this before[1ms,1h] $saleB ) : This means that our TDI it`s starting in the first value (1ms) and it`s ending in our second value (1h). In simple words, the Event will match if the saleA starts between 1 millisecond and 1 hour before the saleB event.
$saleA : Sale( this after[1h,10h] $saleB ) : This means the same as the situation above, but with the difference that the Event will match if the saleA starts between 1 hour and 10 hours after the saleB event.
$saleA : Sale( this after[10h] $saleB ) : This means that our TDI it`s starting in the first value (10h) and it`s ending in the positive infinity. So in simple words, the Event will match if the saleA starts between 10 hours and the positive infinity after the saleB event.
In addtion to these examples, If no value is defined, it is assumed that the initial value is 1ms and the final value is the positive infinity.