Add script support to value_count aggregations.

The diff on the documentation is simply a revert of ba415b8ad21f57801b14d85c102189cfd7cbbf5a

Close #5001