-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{{#toLowercase}} mustache function for search templates #60566
Comments
Pinging @elastic/es-core-infra (:Core/Infra/Scripting) |
We have historically tried to limit the additions we make to languages like mustache. While I understand the desire to have a workaround for the mentioned issues, I do not think search templates are the right place to provide those workarounds. The linked issues are valid on their own, and users should not have to use templates to solve those issues. Given those thoughts above, do you have any other compelling reason for needing a lowercase tag in mustache? It seems the examples provided in this issue can easily be worked around by lowercasing on the client side when generating the search request. |
Totally understand. I've recently seen a video on YouTube, where it gets mentioned how conscious new features are discussed here. I can only agree. And so i'm absolutely fine, if this issue gets closed because of that reason.
Good point.
Of course. If i'm not missing something, the same would also apply for functions like
I only came across the use case i've mentioned above. |
We discussed this issue, and agreed with my original thinking, that opening Mustache up to more customizations is not something we want to do at this time. We will keep this in mind as future needs of mustache come up in new contexts, but for now the particular need about handling wildcard prefixes in templates should be worked around on the client side. As there are no further actions to take here, I hope you don't mind that I close this issue. |
Outline:
As described in this search template reference example there is a mustache function to convert a string to JSON:
{{#toJson}}statuses{{/toJson}}
It would be great to have another mustache function to convert a parameter value string to lowercase:
{{#toLowercase}}genre_prefix{{/toLowercase}}
I'd like to provide a pull request for this feature when discussion leads to an approve for implementation.
Possibly related issues:
Could be an alternate approach for #28894.
Could also be related to #53603.
Use-case:
The Terms Aggregations Filter property "include" supports (among others) regexp queries. These queries are case-sensitive.
A commonly known solution to get case-insensitive results is a "lowercase" Normalizer. The only thing left to do is to use lowercase characters in the regex. I haven't found a solution to do this inside elasticsearch though.
A great way to hide the complexity of some queries and make them exchangeable are Search Templates. Since they come with variables and functions, "toLowercase" could be integrated to get parametrized case-insensitive term aggregations (among others) build into an easy to use search template.
Advantages:
Steps to reproduce:
Proposed solution example:
The text was updated successfully, but these errors were encountered: