-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Today, there is a (little-documented) feature where specifying a field + script on an aggregation will run the script in "value script" mode. Each value in the field will be passed to the script under the _value variable so that the script can modify it, before letting the aggregation collect it.
This is a very trappy API, because there are no safeguards from the user specifying a "normal" script that tries to access regular fields. It can lead to confusion like #20773 and #11728
In #20733, we decided to add a value_script and deprecate field + script combo. Which is certainly doable, but I'm wondering if we should just deprecate the concept of value scripts entirely? I'm not sure how widespread usage actually is?
Besides being confusing, value scripts adds a fair amount of complexity to the code when trying to resolve the ValuesSource, adds another set of Scorer wrappers (ValuesSource.Numeric.WithScript, ValuesSource.WithScript) and adds a bespoke setNextAggregationValue() in the script implementation solely to satisfy this feature.