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
Stored scripts are not supported for runtime field #72827
Comments
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Thanks for the clear recreation @camelia-c . I would be interested to know more about the usecase where stored scripts can be useful in the context of runtime fields. Runtime fields are fields whose values can be computed at runtime and used in any section of a search request. Runtime fields are usually added to index mappings, but they can also be ephemeral, meaning they can be defined directly in the search request in which case the runtime field will be available only in the context of that specific search request. When we developed runtime fields, we decided not to support stored scripts in their index mappings definition, because they are already stored within the index mappings and we did not see value in allowing to store the definition of a runtime field that points to a stored script. It is one more layer of indirection that can be confusing and add complexity while adding little value if none. I can see how it may come in handy when defining a runtime field in the search request, on the other hand given the ephemeral nature of such fields, I wonder if their scripts should/could be stored in the cluster state. Also, the flow will many times be to go from a search defined runtime field to making it permanent in the index mappings, hence adding support for stored scripts to runtime fields defined in the search request translates to supporting them also in runtime fields defined in the index mappings, which I am not sure is a good idea for the reason I stated above. |
Closing for lack of feedback, please feel free to re-open if you are interested in this issue and have feedback around it. |
@javanna here is an example where it would be beneficial to allow runtime fields to access/reuse stored scripts |
@javanna hi! Everything you said makes sense, but a couple of points I think are relevant:
Not necessarily saying it's the most urgent thing ever, but if it's trivial to support I would definitely see more benefit than harm. At the very least I think the docs need to clearly state that stored scripts don't work; unless I'm crazy this isn't mentioned anywhere. |
Thanks for the feedback @whitfin , I also missed a previous reply, sorry @consulthys ! I will reopen this for discussion. |
Thanks @javanna! Just one more note on this but if it is decided to keep this unsupported, the docs at https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html should be updated, specifically:
This in particular is what led me astray in expecting this to work on |
Hello,
I am interested in the following functionality which is not yet supported in Elasticsearch 7.12.1
Here is a minimal example:
and a stored script:
For now, we can successfully use the stored script to return a scripted field in the result:
Yet this cannot be used in filtering, because it's computed in the fetch stage of the execution plan.
The newly released runtime mappings accept inline source code, but it would be great to have them accept stored scripts too.
For now, if we try:
then we get error:
Till the support for stored scripts will be added, the query needs to be written as:
Thanks in advance,
Camelia
The text was updated successfully, but these errors were encountered: