Add script support to value_count aggregations.

Close #5001