I browsed a few topics but couldn't find a similar example. I basically want a Watch set up, searches for keyword and emails (as attachment) any files it finds with that keyword. It works if I hardcode the filename in the URL (ie Attachment.pdf), if I try and use mustache templating it errors at Watch creation time with "results in error "Malformed URL [{{ctx.payload.hits.hits.0._source.filename}}]""
If I try and use just ctx.payload.hits.hits.0._source.filename without the brackets, then it sends that literal text to my webserver, which of course doesn't know what ctx.payload.hits....filename is and my webserver errors.
"trigger" : {
"schedule" : {
"interval": "12h"
}
},
"input" : {
"search" : {
"request" : {
"body" : {
"query": {
"match": {
"_all" : "keyword"
}
}
}
}
}
},
"condition" : {
"compare" : {
"ctx.payload.hits.total" : {
"gt" : 0
}
}
},
"actions" : {
"email_admin" : {
"email" : {
"to" : "me@company.com",
"subject" : "Keyword found!",
"attachments" : {
"heaven.pdf" : {
"http" : {
"content_type" : "application/pdf",
"request" : {
"url": "http://localhost:8000/{{ctx.payload.hits.hits.0._source.filename}}"
}
}
}
}
}
}
}
A sample response from my keyword search
"file": {
"extension": "pdf",
"content_type": "application/pdf",
"last_modified": "2017-09-05T11:30:51.605+0000",
"indexing_date": "2017-09-12T17:01:22.214+0000",
"filesize": 93745,
"filename": "7-19-17 CC - Linn Ann Jones Griffin.pdf",
"url": "file://c:\\express\\agendakeyword\\BoardDocs\\7-19-17 CC - Linn Ann Jones Griffin.pdf"
},
"path": {
"root": "7511c68c2ea637f9d0867848d06b7d55",
"virtual": "/7-19-17 CC - Linn Ann Jones Griffin.pdf",
"real": "c:\\express\\agendakeyword\\BoardDocs\\7-19-17 CC - Linn Ann Jones Griffin.pdf"
}
}
I don't understand why I'm getting a malformed error. Thanks