Hi! I'm trying to create an email message based on the number of hits. For instance, I would iterate through the ctx.payload.hits.hits list and display simple text in the email body listing a couple of properties from the found events. For achieving this I studied the scripting capabilities e.g. this page but found that the script enclosed by the three double quotes are not JSON syntax. Hence this is cannot be put into the Kibana's watcher editor or any other JSON editor. What was your intention with this syntax? It caused me a lot of headaches.
This is probably a question best asked here: https://discuss.elastic.co/c/elasticsearch
As it's not Kibana-related. I'm not sure why the example would have been written that way. It looks like maybe a bug in the way our docs get generated. Here's the correct string representation:
"return [\n 'money_makers': ctx.payload.aggregations.theatres.buckets.stream() \n .filter(t -> { \n return t.money.value > 50000\n })\n .map(t -> { \n return ['play': t.key, 'total_value': t.money.value ]\n }).collect(Collectors.toList()), \n 'duds' : ctx.payload.aggregations.theatres.buckets.stream() \n .filter(t -> {\n return t.money.value < 15000\n })\n .map(t -> {\n return ['play': t.key, 'total_value': t.money.value ]\n }).collect(Collectors.toList())\n ]"
Actually, it does not work. It seems the only way to separate a string into multiple lines if every line enclosed by quotes and every line terminated by a comma. This is the JSON array syntax. See this here.. Whenever you put a new line into a "script" property you get an "invalid JSON" error in the Kibana's watch editor. It's really painful to write any significant script in one line. Did I miss something?
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.