Convert MySQL query to elasticsearch

Thanks a lot Bragin,
You got my question. Now I understand the scripted field based on data from a single document and had a idea about Date Histogram. As you mentioned, My case is need to go across document. Now my question is how to get the maximum and minimum value of a field from across document? Would you please explain me a little bit detail.