有时候我们想对es query出来的数据在action发送邮件时以表格的形式发送,可以参考下面的方法:
"action": {"test_send_email": { //action name"email": { //action type"to": ["abc@xxxx.com","ABC@xxxx.com"],"subject": "Test Elasticsearch Action Send Email","body": {"html": "<table><tr><th>name</th><th>age</th><th>sex</th></tr> {
{#ctx.payload.hits.hits}} <tr><td> {
{_source.name}} </td><td> {
{_source.age}} </td><td> {
{_source.sex}} </td></tr> {
{/ctx.payload.hits.hits}} </table>"}}}
}//<th>中表示的是列名,<tr>中是获取对应的字段值