You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/plain_rules.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ The “anatomy” of a rule is as follows
7
7
```json
8
8
{
9
9
"name":"blood_rule_update",
10
-
"text":"select *,\"blood_rule_update\" as ruleName, *, ev.BloodPressure? as Pressure, ev.id? as Meter from pattern [every ev=iotEvent(cast(cast(BloodPressure?,String),float)>1.5 and type=\"BloodMeter\")]",
10
+
"text":"select *, *, ev.BloodPressure? as Pressure, ev.id? as Meter from pattern [every ev=iotEvent(cast(cast(BloodPressure?,String),float)>1.5 and type=\"BloodMeter\")]",
11
11
"action":{
12
12
"type":"update",
13
13
"parameters":{
@@ -36,16 +36,16 @@ EPL is documented in [Esper website](http://www.espertech.com/esper/esper-docume
36
36
A EPL statement to use with perseo could be:
37
37
38
38
```
39
-
select *, "blood_rule_update" as ruleName,
40
-
ev.BloodPressure? as Pressure, ev.id? as Meter
39
+
select *, ev.BloodPressure? as Pressure, ev.id? as Meter
41
40
from pattern
42
-
[every ev=iotEvent(cast(cast(BloodPressure?,String),float)>1.5 and type="BloodMeter")]
41
+
[every ev=iotEvent(cast(cast(BloodPressure?,String),float)>1.5 and type="BloodMeter")]
43
42
```
44
43
45
-
46
-
* The rule name must be present with **ruleName** alias. It must be equal to the ‘name’ field of the rule object
47
44
* The *from* pattern must name the event as **ev** and the event stream from which take events must be **iotEvent**
48
45
* A *type=* condition must be concatenated for avoiding mixing different kinds of entities
46
+
* The variable 'ruleName' in automatically added to the action, even if it is not present in the EPL text. The ruleName automatically added this way is retrieved as part of the EPL text when the rule is recovered using GET /rules or GET /rules/{name}.
47
+
48
+
**Backward compatibility note:** since version 1.8.0 it is not mandatory to specify the name of the rule as part of the EPL text. In fact, it is not recommendable to do that. However, for backward compatibility, it can be present as *ruleName* alias (`e.g: select *, "blood_rule_update" as ruleName...`) in the select clause. If present, it must be equal to the ‘name’ field of the rule object.
49
49
50
50
The used entity's attributes must be cast to `float` in case of being numeric (like in the example). Alphanumeric
51
51
values must be cast to `String`. Nested cast to string and to float is something we are analyzing, and could be
@@ -527,7 +527,7 @@ could be used by a rule so
527
527
```json
528
528
{
529
529
"name": "blood_rule_email_md",
530
-
"text": "select *,\"blood_rule_email_md\" as ruleName, *,ev.BloodPressure? as Pression, ev.id? as Meter from pattern [every ev=iotEvent(cast(BloodPressure__metadata__crs__system?,String)=\"WGS84\" and type=\"BloodMeter\")]",
530
+
"text": "select *, *,ev.BloodPressure? as Pression, ev.id? as Meter from pattern [every ev=iotEvent(cast(BloodPressure__metadata__crs__system?,String)=\"WGS84\" and type=\"BloodMeter\")]",
531
531
"action": {
532
532
"type": "email",
533
533
"template": "Meter ${Meter} has pression ${Pression} (GEN RULE) and system is ${BloodPressure__metadata__crs__system}",
@@ -666,7 +666,7 @@ An example of rule taking advantage of these derived attributes could be:
666
666
```json
667
667
{
668
668
"name": "rule_distance",
669
-
"text": "select *, \"rule_distance\" as ruleName from pattern [every ev=iotEvent(Math.pow((cast(cast(position__x?,String),float) - 618618.8286057833), 2) + Math.pow((cast(cast(position__y?,String),float) - 9764160.736945232), 2) < Math.pow(5e3,2))]",
"text": "select *, \"badRuleleName\" as ruleName, ev.xPressure? as Pression, ev.id? as Meter from pattern [every ev=iotEvent(cast(cast(xPressure?,String),float)>1.5 and type=\"xMeter\")]",
4
+
"action": {
5
+
"type": "post",
6
+
"template": "Meter ${Meter} has pression ${Pression}.",
"text": "select *, ev.xPressure? as Pression, ev.id? as Meter from pattern [every ev=iotEvent(cast(cast(xPressure?,String),float)>1.5 and type=\"xMeter\")]",
4
+
"action": {
5
+
"type": "post",
6
+
"template": "Meter ${Meter} has pression ${Pression}.",
0 commit comments