I think at this point we would probably not remove the scripted metric aggregation without a deprecation period and a suitable replacement for the types of analytics users are using it for. The experimental tag still exists because up to this point we have not been completely happy with its API and this is something we are working to solve with changes like https://github.com/elastic/elasticsearch/pull/30111.
I think there is likely to always be a place for writing custom aggregation logic using a script (at least while creating a plugin that adds a new aggregation is still complex) but I would always see it as a last resort. Many times I have seen users reach for the scripted_metric aggregation before fully exploring whether their use case can be solved in a different way with the current aggregations. I am not saying that your case is one of these but I would advise exploring options for not using the scripted_metric aggregation where you can.
Also, as we are always looking to expand the list of out of the box aggregations, if your use case feels like it might be generally useful then feel free to open an issue on the Elasticsearch Github repo and we can explore whether we should build a dedicated aggregation to solve use cases like yours.
thanks for the heads up and valuable information @colings86 .
Didn't want to stray offtopic but the usecase I'm trying to solve is
currently we sum over single field. but I want to sum up over 1 field and if that field is not present then some another field should be added to the sum.
PS. I always wanted to thank someone from elasticsearch for such a great & heavy duty thing. So "thanks"
So for your use case I would use the sum aggregation but instead of specifying the field I would specify a script option something like the following (disclaimer: I have not tested this so the syntax might need a bit of tweaking):
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.