-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
TL;DR I want to get all the search templates defined in the cluster metadata and I am willing to implement it myself
I found myself needing to get all the search templates defined in the cluster metadata. Noticed that there was no endpoint to get all the templates, so I though I should just add it myself. After diving into the code, I noticed why it is not currently implemented.
Templates are just scripts, so the search template endpoints end up going through the script service, which does not support getAll. The actual scripts are stored in a collection referenced only by the id. I thought I implement a hack by simply iterating through all the script and looking at the key name, but the lang context has been recently removed. I could create another data structure to keep track of the lang context, but I do not like the idea of supporting different data structures (basically multi key maps).
There has been some discussion about splitting templates from scripts (#16314) with an initial attempt by @nik9000 (#23744). I did not review the rejected PR, but perhaps it would support exactly what I need. If not, this separation would have been useful since the template service would support my (eventual) PR.
My next step would be to implement a generic getAllStoredScripts type class/method, which would support a lang param. Two issues come to mind:
- The implementation for my use case would be rendered obsolete if Split templates from scripts? #16314 gets implemented.
- Would highlighting all the scripts be a security concern? Due to potential overload, I would have implemented it as a cat endpoint with the actual script not being returned (I just need names).
Would it be wise to implement such an endpoint? I do not want to code something, only to have a fail to be picked up for non-technical reasons.