Add statistical mode and median

Hi! I'm using elasticsearch with a big dataset (over 17000000 row in a mysql database) and I have to find the median value and the mode on a specific field. I've watched the facets and the sort but it's not useful for me. With the sort I've to return all the values and it is very slow, in the statistical facets there aren't the median and the mode. Sorry for my bad english, thank u all!