blob: 6ee14933d45d8b5dde2c71b50bde727774a86259 [file] [log] [blame]
ac25505082fd72018-03-20 12:35:48 +01001{
2 "query" : {
3 "match_all": {}
4 },
5 "script_fields" : {
6 "timeSince" : {
7 "script" : {
8 "lang": "painless",
9 "source": "
10long now = System.currentTimeMillis();
11if (doc.get('closedLoopEventStatus.keyword').value == 'ABATED') {
12 return now - doc.get('closedLoopAlarmEnd').value;
13}
14if (doc.get('closedLoopEventStatus.keyword').value == 'ONSET') {
15 return now - doc.get('closedLoopAlarmStart').value;
16}
17if (doc.containsKey('notification.keyword')) {
18 return now - doc.get('notificationTime').value;
19}
20
21return null
22"
23 }
24 }
25 , "closedLoopAlarmStart" : {
26 "script" : {
27 "lang": "painless",
28 "source": "doc['closedLoopAlarmStart']"
29 }
30 }
31 , "closedLoopEventStatus" : {
32 "script" : {
33 "lang": "painless",
34 "source": "doc['closedLoopEventStatus.keyword']"
35 }
36 }
37 , "notification" : {
38 "script" : {
39 "lang": "painless",
40 "source": "doc['notification.keyword']"
41 }
42 }
43 , "notificationTime" : {
44 "script" : {
45 "lang": "painless",
46 "source": "doc['notificationTime'].value"
47 }
48 }
49
50 }
51}