-
Notifications
You must be signed in to change notification settings - Fork 119
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
Allow expressions to compute keys #56
Comments
That feature would help me so much! |
Could you show an example of how you would use it? That would be helpful for me. |
Sure! One use case I have is to generate Elasticsearch queries from a business-specific DSL, using JSLT, which allows me for far more sophisticated templating than Elasticsearch native templating (based on mustache.js)! Here's a sample JSLT :
This does not compile. This is only a very simple query, it could be much more complex, but basically I always have to use a field name as a key to specifiy some operation on it, be it a search operation, a highlight, an aggregation. Currently I have to build a JSON string instead and the use the |
This makes sense. Thank you! Yes, I think we should add support for this. I'll see if I can get it done. |
Now I find I need this feature myself. |
Some issues that need to be worked out. Dynamic keys in objects that use the object matcher. Since we don't know at compile-time what keys are defined in the matcher the matching behaviour becomes more complex. Possible solution: forbid dynamic keys in matchers. What if the key expression produces something that's not a string? We consider this an error. What if the key expression ends up producing a duplicate key? Duplicate literal keys are forbidden at the moment. Consider this an error? |
Fixed in commit 7342c95 |
Issue #55 demonstrates that there might be a need for being able to write objects like this:
There doesn't seem to be any clear reason why this couldn't be supported.
The text was updated successfully, but these errors were encountered: